Scaled/weighted density plot
And to do this in base (using DanM's data):
plot(density(dat$Temperature,weights=dat$Number/sum(dat$Number),na.rm=T),type='l',bty='n')
I think you can get what you want by passing a weights
argument to density
. Here's an example using ggplot
dat <- data.frame(Temperature = sort(runif(10)), Number = 1:10)
ggplot(dat, aes(Temperature)) + geom_density(aes(weights=Number/sum(Number)))