Lasse Lasse - 11 months ago 78
R Question

Knitr-error from Task Schedule Manager

I am trying to set up a task that runs a batch-file, that runs a

file which should knitr me a lovely
file each day.

Everything works fine, if I run the batch-file manually. However, when I run it through the task scheduler, I get the following error from the command prompt:

Error in file(con, "w") : cannot open the connection
Calls: <Anonymous> -> knit -> writeLines -> file
In addition: Warning message:
In file<con, "w") : cannot open file '" : Permission denied
Execution halted

The same user is listed as the "author" in the task-scheduler, as the user when you open the start menu.

Batch-file code:

"C:\R\R-3.0.3\bin\x64\Rscript.exe" -e "library(knitr,dplyr); knitr::knit2html('C:/R/Rapporter/residual_model/Residual_v1.Rmd')"

Im am at a loss of what to do.

Answer Source

It looks you do not have write permission in the working directory of R. I'd recommend you to set the working directory before you run knit2html(), e.g.



"C:\R\R-3.0.3\bin\x64\Rscript.exe" -e "setwd('C:/R/Rapporter/residual_model/'); knitr::knit2html('Residual_v1.Rmd')"

Or any other output directory in which you have write permission: