[R] textbox in lattice
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Jun 2 07:55:21 CEST 2010
On Wed, Jun 2, 2010 at 12:37 AM, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Please do read the posting guide, in particular regarding reproducible examples.
>
> You can use a Grid layout to place the lattice plot and a table in the
> same page. For example,
>
> library(lattice)
> library(coda)
> library(gridExtra)
> x <- matrix(runif(2200),ncol=22)
> m <- as.mcmc(x)
> p = xyplot(m, layout = c(2, 11))
>
> pdf(,height=15)
> arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
> heights= unit(c(3,1),"null"))
> dev.off()
Something like this should also work, except that the grob produced by
tableGrob() doesn't seem to know its height.
splom(iris,
sub = tableGrob(as.matrix(summary(iris)),
gp=gpar(cex = 0.5)))
A quick alternative using lattice::draw.key() is
tableKey <- function(x)
{
key <- list()
for (i in 1:ncol(x))
{
labels <- c(colnames(x)[i], x[,i])
font <- c(2, rep(1, nrow(x)))
key <- c(key, list(text = list(labels, font = font)))
}
draw.key(key, draw = FALSE)
}
splom(iris, sub = tableKey(as.matrix(summary(iris))))
-Deepayan
More information about the R-help
mailing list