J_F
J_F

Reputation: 10372

knitR/RMD: select output folder

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

Upvotes: 4

Views: 3612

Answers (2)

Felipe Gerard
Felipe Gerard

Reputation: 1622

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!

Upvotes: 0

jimjamslam
jimjamslam

Reputation: 2067

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.

Upvotes: 1

Related Questions