4

I'm using a RMD file to create a package vignette. My. rmd file is stored in

 .../path_to_package/vignettes/vignette.rmd

When creating a PDF the last line in the R Markdown console window is "Output created: /tmp/....".

How is it possible to create the PDF directly in the vignettes folder and not in a /tmp/.. folder?

I'm using Ubuntu 14.04 LTS and R 3.3.0, rmarkdown 0.9.6 and knitr 1.13.

Regards,

Johannes

J_F
  • 9,956
  • 2
  • 31
  • 55
  • 1
    not sure I understand the question, isn't the typical behavior to output the PDF in the same folder that the RMD file is stored in? Is this not what is happening for you? – user5359531 May 13 '16 at 03:20
  • No, that's not the case for me. – J_F May 13 '16 at 06:02
  • 2
    I think this is related to [this previous question](http://stackoverflow.com/questions/20060518/in-rstudio-rmarkdown-how-to-setwd). Seems like the most straight-forward option would be to set `opts_knit` (as in the link above) or in [this potential workaround](http://stackoverflow.com/questions/28894515/rmarkdown-directing-output-file-into-a-directory). It also appears others have [shared your pain](https://github.com/yihui/knitr/issues/913) or something similar. – Tad Dallas Jun 15 '16 at 06:13
  • Thanks for the links. I now realized that when using `render("/path_to_my_file.Rmd")` the output folder is the same as the input *.Rmd file. But when using the `KnitPDF` button in RStudio, the files is stored at "/tmp/..." – J_F Jun 15 '16 at 08:26

2 Answers2

1

rmarkdown::render does indeed output to the same directory as the input folder by default, but you can override that by supplying an output_dir argument to it (and an output_file one if you'd like to specify a different filename to the input file too).

I'm not sure why the Knit button in RStudio is doing something different for you—in my case it also outputs to the same folder as the source (even when I haven't specified a working folder and my home directory is the default), and RStudio doesn't show the function it's calling when you click the button, so it's a little hard to be sure. I'd stick to using rmarkdown::render() with the specified arguments for now.

jimjamslam
  • 1,988
  • 1
  • 18
  • 32
0

Instead use

devtools::build_vignettes()

It will automatically put the files where they're supposed to go. Also check out Hadley Wickham's guide. It rocks!

Felipe Gerard
  • 1,552
  • 13
  • 23