I have a graph that looks like so, and want to plot the peaks on it:
this is my current code:
ggplot(df,aes(x=xval,fill=sample)) +
geom_density(alpha=.5)+
xlim(c(median(xval)-0.001,median(xval)+0.001))+
labs(title=paste0("Title ",datetoday),x="intensity",fill="concentration")+
ggsave((paste0("file ",datetoday,".png")))
whenever I try to add stat_peaks to my graph, it gives me the error 'Error: stat_peaks requires the following missing aesthetics: y' - but I'm not sure how to set the y value to the density.
TIA