When working locally, I use the following to render rmarkdown documents:
rmarkdown::render(input = rmd.temp , output_dir = out.dir, output_file = out.name)
Error in replayPlot(x) :
could not open file'/...path..../figure-html/unnamed-chunk-2-1.png'
df <- data.frame(a=1:10)
write.csv(df, file = "df.csv")
Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection
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.