4

I am trying to get R Markdown and knitr to work on a linux server with restricted access. In particular: specific file types have to go into specific folders and creating new folders is impossible. Deleting files is also not possible (but overwriting is). R Markdown and knitr seem to want to create a range of files and folders with limited control where what goes. There seems to be some way to make specifications on a chunk by chunk basis, but this would not work without a lot of user training. Is it possible to specify separate paths for all the inputs and outputs, including:

  • Input document (could be set using rmarkdown::render())
  • Figures created by the chunks (cannot be set using rmarkdown::render())
  • *.md, *.tex, *.aux and other intermediary files (could be set using rmarkdown::render())
  • *.log files (cannot be set using rmarkdown::render())
  • Final output file (e.g. PDF) (could be set using rmarkdown::render())

Ideally the solution should work both for R Studio and basic R, but partial solutions are welcome.

Rob Hall
  • 1,358
  • 3
  • 11
  • 17
  • 1
    I'm not sure this is possible without a lot of hassle. Can't you ask your system admin for writing permission for one directory? That's all you need. Then knitr can go ahead and create all the files it needs during the "knitting" process. – csgroen Apr 10 '18 at 13:48
  • @csgroen There is some granularity in rmarkdown::render() (see: [link](https://www.rdocumentation.org/packages/rmarkdown/versions/1.9/topics/render)), just not quite enough. knitr has some options to define where e.g. figures should go (see [link](https://yihui.name/knitr/options/#chunk_options)), but there seems to be no way to globally set it. So it seems to me like there should be some way to make what I am looking for work, but I was unable to find a good way to set it up. – Rob Hall Apr 10 '18 at 15:27
  • is [this](https://stackoverflow.com/a/46007686/7552816) answering a bit (there is also the accepted answer) ? Also you can indeed set the folder for the figures or maybe you coudl change the working directory ? – R. Prost Apr 11 '18 at 05:26
  • Thank you @R.Prost . This potentially helps with using the GUI button. Sadly rmarkdown::render() only allows setting 3 out of 5 locations mentioned above. The most annoying thing is that it puts figures into newly created subdirectories, which I need to avoid. I am willing to call e.g. knitr:knit() manually to get more control, but I am still not clear on how I can prevent these subdirectories. – Rob Hall Apr 11 '18 at 08:23

0 Answers0