Re: [R] textbox in lattice

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Wed, 02 Jun 2010 11:25:21 +0530

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 02 Jun 2010 - 06:01:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 07:50:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive