Knitr-error from Task Schedule Manager
batch-file, knitr, r
Solution
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.
setwd('C:/R/Rapporter/residual_model/')
knitr::knit2html('Residual_v1.Rmd')
i.e.
"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:
setwd('any/output/directory/you/want')
knitr::knit2html('C:/R/Rapporter/residual_model/Residual_v1.Rmd')
Problem
I am trying to set up a task that runs a batch-file, that runs a `.rmd` file which should knitr me a lovely `.html` 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 'residual_v1.md" : 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.