Hi,
I wrote a basic geom_table that one can use with annotate to add a
table at a specific location in a ggplot. The table is typically drawn
from a data.frame but it may contain only a single row/column. I
defined some specific lists of settings for the appearance,
unfortunately these themes appear quite redundant with ggplot2's own
theming system because ggplot2 does not define theme elements for the
geoms.
library(ggplot2)
library(ggExtra) #
http://code.google.com/p/ggextra/
x<-rnorm(1:20)
y<-x+rnorm(1:20)
xrng<-range(x)
yrng<-range(y)
p <- qplot(x,y)
caption <- as.data.frame(strwrap("Adj.means: first= .111 second=
.222 third= .333",15))
p + annotate("table", table=caption, x=1, y=-2, theme=theme.list()) + theme_bw()
reg<-lm(y~x)
beta1<-reg$coefficients[1:2]
caption <- as.data.frame(round(beta1,3))
p + annotate("table", table=caption, x=1, y=-2,
theme=theme.list(show.rownames=T, show.colnames=T),
cols=expression(beta[1]))
HTH,
baptiste