I am trying to add a legend to a density plot generated via ggplot2, but instead of adding sample labels, I am trying to fill the legend with numbers.
library(ggplot2)
library(modeest)
set.seed(9)
d1=as.data.frame(rnorm(1000,mean=0.33,sd=0.138))
names(d1)=c("value")
mean_d1=mean(d1$value) #Mean=0.33081
mode_d1=mlv(d1$value,method="shorth")[1] #Mode=0.35191
gg=ggplot(d1,aes(value))
gg +
geom_density()
Is there a way to add a legend (embedded in the upper right corner) which contains the mean and mode values I have already calculate?