Pete900 Pete900 - 11 months ago 79
R Question

Render rmarkdown from RStudio server to external drive

When working locally, I use the following to render rmarkdown documents:

rmarkdown::render(input = rmd.temp , output_dir = out.dir, output_file =

This gets my template doc
, then renders the document to
and names the file

I am trying to replicate on a RStudio server. When
is a local directory the code works fine. However, when
is a mapped directory to an external drive, I get the following error:

Error in replayPlot(x) :
could not open file'/...path..../figure-html/unnamed-chunk-2-1.png'

The link to the mapped drive works because I can use:


and see the new folder appear. Any ideas why the rendering gets stuck?


This is perhaps just a permission problem because I can't write a csv file either:

df <- data.frame(a=1:10)


write.csv(df, file = "df.csv")

Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection

RStudio server is running on Ubuntu. I will open a new question on how to give RStudio folder permissions.

Answer Source

For anyone who has this problem, it can be fixed by adding this to the start of your script:


It was a permission problem. From the shell / command line, global permission was "0000" but from the RStudio console it was "0002", which produces -rw-r-- permissions for new files. The global permission can probably be changed for RStudio but this works.