I pulled this together from some code that someone else helped me put together (In other words I don't fully understand everything that it going on... yet). It seems to work, but you have to specify the coordinates manually according to your data.
d=data.frame(x=1:10,y=runif(10))
p=ggplot(d,aes(x,y))+geom_point()
m <- lm(y ~ x, data = d)
eq <- substitute(italic(r)^2~"="~r2, list(r2 = format(summary(m)$r.squared, digits = 3)))
dftext <- data.frame(x = 1, y = 1, eq = as.character(as.expression(eq)))
p + geom_text(aes(label = eq), data = dftext, parse = TRUE)
HTH,
Brandon
On Sun, Jul 25, 2010 at 04:00, blessedboy
<kah...@gmail.com> wrote:
d=data.frame(x=1:10,y=runif(10))
p=ggplot(d,aes(x,y))+geom_point()