Skip to content
Prev 295686 / 398503 Next

sweave tables as images?

you can open a device that has the exact dimensions of the table,

g = tableGrob(head(iris, 4))
png("test.png", width=convertWidth(grobWidth(g), "in", value=TRUE),
        height=convertHeight(grobHeight(g), "in",
value=TRUE),units="in", res=150)
grid.draw(g)
dev.off()

Doing this with knitr might be tricky though, since the unit
conversion opens a blank device window, and you'd want to define some
hook instead of manually creating the png file.

I have another version of grid.table where you can specify the width
and height manually [*], e.g to span the full window, but it's not
necessarily a desirable thing (the spacing between rows and columns
can become too large).


HTH,

baptiste


[*] experimental code at https://gist.github.com/2013903
On 26 May 2012 09:16, Alexander Shenkin <ashenkin at ufl.edu> wrote: