[R] Adding a table to a lattice plot
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Jan 23 01:16:51 CET 2008
On 1/22/08, Judith Flores <juryef at yahoo.com> wrote:
> Hi,
>
> Is there an analog function of textplot in the
> lattice package? I need to add a data frame to a
> lattice plot. I work in a Windows environment and I am
> using R v 2.6.1
There's nothing built-in, but if you are happy with fixed width text,
a simple wrapper to capture.output() should be good enough. Here's one
approach:
panel.textplot <-
function(object, ...,
gp = gpar(fontfamily = "mono"))
{
require(grid)
foo <- capture.output(object)
grid.text(paste(foo, collapse = "\n"), ..., gp = gp)
}
xyplot(1 ~ 1,
panel = function(...) {
panel.xyplot(...)
panel.textplot(head(iris))
})
You could use other arguments to grid.text() in the call to
panel.textplot(), giving a fair amount of control over placement etc.
-Deepayan
More information about the R-help
mailing list