print ggplot2 summary on graphic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

print ggplot2 summary on graphic

Felipe Carrillo
Hi all: The code below works well to print annotations
on base graphics but I can't make it work using the
ggplot2 package. I tried to use the capture.output
function but only prints the summary on the R console
and no on the graphic. Any ideas on how to print
output on ggplot2 graphs? For a powerpoint
presentation I basically just want to show viewers the
mean and Median on the graph since they won't be
seeing the data or the R console.
aa <- 1:10
text(c(2,4),10, labels=c( "mean", "sd"),col=2)
text(c(2,4),9.5, labels=c(mean(aa), sd(aa)),col=4)

m <- ggplot(movies, aes(x=rating))
m + geom_density()

Felipe D. Carrillo
  Fishery Biologist
  US Fish & Wildlife Service
  California, USA

Looking for last minute shopping deals?

[hidden email] mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.