Is it possible to annotate a ggplot figure with a "text" element indicating a feature of the data (variable)?
library(ggplot2)
library(datasets)
my.mean <- mean(mtcars$mpg, na.rm=T)
my.mean <- as.name(my.mean)
gplot <- ggplot(mtcars, aes(mpg))+geom_histogram()
gplot <- gplot + geom_text(aes_string(label=my.mean, y=5), size=3)
This produces something on the plot that looks like a succession of numbers. Any ideas how to resolve this?
Edit: this question is different since I am not trying to annotate each histogram bin with a value. The objective is to add one single text element to the plot.