3

I have a client who would like to use Rmarkdown to make figures into a Word Document and then edit them (I know... not really the point of reproducible research, but it's what the client wants...)

 ----
 title: "MinReproEx_Metafile" 
 author: "Erika Mudrak" 
 date: "Thursday, July 17, 2014" 
 output: word_document
 ----

 Try to put a bigger metafile figure in a work document 

 ```{r, echo=FALSE, dev='win.metafile', fig.height=6, fig.width=6}
 plot(cars) 
 ```

Using dev='win.metafile' places the figure as an editable metafile, but regardless of the input for fig.height and fig.width the figure is 1.67 x 1.67 inches. So somehow the dev='win.metafile' overrides these chunk options.

The knitr option page has this about dev.args:

dev.args: (NULL) more arguments to be passed to the device, e.g. dev.args=list(bg='yellow', pointsize=10); note this depends on the specific device (see the device documentation); when dev has multiple elements, dev.args can be a list of lists of arguments with each list of arguments to be passed to each single device, e.g. <>=

Where can I find the device documentation for the metafile format to which this refers?

Spacedman
  • 92,590
  • 12
  • 140
  • 224
emudrak
  • 789
  • 8
  • 25
  • The documentation is in `?windows` but you'll only have than on a windows build IIRC. You don't need to use a metafile to dump into a word document. It should be fine with PNG, TIFF, or EPS as well - unless you mean they physically want to edit the metafiles in place. Then, errr, Yuck. – Gavin Simpson Jul 29 '14 at 16:43
  • You might want to take a look at [this](http://gforge.se/2014/07/fast-track-publishing-using-rmarkdown/) recent posting by Max Gordon on RMarkdown. He mentions `out.width` etc there and discusses a new package that adds capabilities such as `force_captions` that might work for you. – Gavin Simpson Jul 29 '14 at 16:56

1 Answers1

0

Try out.height=6, out.width=6. (try different numbers) If still does not work, just tell them copy the figures from the figure/ file folder (usually in the same directory as your Rproj) and then paste in their doc files. Knitr saves all figures in your computer if cache=TRUE.

Daijiang Li
  • 697
  • 4
  • 16
  • As the document is in markdown and that markup "language" has no concept of figure widths and heights `out.width` and `out.height` get converted to raw HTML in the rendered `md` document (as you go from `Rmd` to `md`). What Pandoc then does with such input when rendering to a `doc[x]` file is another question altogether. – Gavin Simpson Jul 29 '14 at 15:57