Re: [R] sweave tables as images?

2012-05-25 Thread Yihui Xie
The hook function hook_pdfcrop() also works on PNG images, although the function name is somehow misleading. The requirement is that you have ImageMagick installed and the command 'convert' is in your PATH. It is a contribution from @r2d3 https://github.com/yihui/knitr/issues/209#issuecomment-52665

Re: [R] sweave tables as images?

2012-05-25 Thread Yihui Xie
Normally I hate the device()+code+dev.off()+cat('\\includegraphics{}) trick. Let me show you how trivial this can be in knitr: https://gist.github.com/2790922 This example shows the real source code to the reader (device()+dev.off() makes no sense to them), and leaves all the dirty tricks behind t

Re: [R] sweave tables as images?

2012-05-25 Thread baptiste auguie
My guess is that it would be impossible to use the table size in Sweave, only mildly non-trivial in knitr with a proper hook. The easiest hack in either of them would be to manually open the png device, and use cat() with \includegraphics{} where you want the plot diplayed. HTH, b. On 26 May 201

Re: [R] sweave tables as images?

2012-05-25 Thread Alexander Shenkin
this works - thanks baptiste! i'm working in Sweave right now - perhaps it will be tough in knitr as you mention. On 5/25/2012 4:31 PM, baptiste auguie wrote: > you can open a device that has the exact dimensions of the table, > > g = tableGrob(head(iris, 4)) > png("test.png", width=convertWidth

Re: [R] sweave tables as images?

2012-05-25 Thread baptiste auguie
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

Re: [R] sweave tables as images?

2012-05-25 Thread Alexander Shenkin
Thanks Yihui, That's a great idea, and comes close to the mark, except that I have to use png's in order to "Insert & Link" them as pictures in Word (and hence make the doc both shareable and update when new figures are generated). thanks, allie On 5/25/2012 2:57 PM, Yihui Xie wrote: > You may t

Re: [R] sweave tables as images?

2012-05-25 Thread Yihui Xie
You may take a look at knitr's graphics manual which tells you how you can automatically crop the white margins: https://github.com/downloads/yihui/knitr/knitr-graphics.pdf ("Cropping PDF Graphics"). I'm not sure if pdfcrop works in this case, though. Regards, Yihui -- Yihui Xie Phone: 515-294-2

Re: [R] sweave tables as images?

2012-05-25 Thread Alexander Shenkin
grid.table() works well, but using it in sweave creates graphics with very wide margins. I'm sure this has something to do with grid, and not just grid.table. Any idea how I can clip the graphic to the edges of the table graphic? I've looked into viewports, etc, but I can't seem to find anything

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Tue, May 22, 2012 at 3:24 PM, Alexander Shenkin wrote: > If I understand it correctly, odfWeave doesn't have a path backwards > from the odf doc back to the original odfWeave doc (which is the main > restriction of all these Sweave/knitr/etc solutions in my use case). > Please correct me if I'm

Re: [R] sweave tables as images?

2012-05-22 Thread Alexander Shenkin
Thanks Liviu, I've looked into SWord, and while it's an impressive project, I'm concerned that it doesn't quite give me the fine-grain control I'd like over the R environment where it's being executed. It's still in the back of my mind though, and I may indeed go with it at some point. If I unde

Re: [R] sweave tables as images?

2012-05-22 Thread Liviu Andronic
On Mon, May 21, 2012 at 10:29 PM, Alexander Shenkin wrote: > So, I think it will be better if I can somehow generate the tables as > images.  Is there any way to generate tables as images in separate files > in Sweave?  Or, is there another tree up which I should be barking? > Hmm, there are Sweav

Re: [R] sweave tables as images?

2012-05-21 Thread Alexander Shenkin
Thanks Michael - I think grid.table does the trick. On 5/21/2012 3:33 PM, R. Michael Weylandt wrote: > Take a look at addtable2plot in plotrix or grid.table / tableGrob in > gridExtras. > > Michael > > On Mon, May 21, 2012 at 4:29 PM, Alexander Shenkin wrote: >> Hello folks, >> >> I've been on a

Re: [R] sweave tables as images?

2012-05-21 Thread R. Michael Weylandt
Take a look at addtable2plot in plotrix or grid.table / tableGrob in gridExtras. Michael On Mon, May 21, 2012 at 4:29 PM, Alexander Shenkin wrote: > Hello folks, > > I've been on a journey trying to figure out how to manage documents that > are amenable to sharing and editing, but that contain d