I want to run Rmarkdown from the command line that will save an HTML output (I don't care if the command line shows me the plot as it's run or not, as long as the result is saved).
My Rmd script is something like:
---
title: "Report"
output: html_document
---
`r load("C:/Users/durlij/Desktop/Reports/.RData")`
## This is the Report as of `r format(Sys.Date(), format="%B %d %Y")`.
`r library(knitr)`
```{r error = FALSE, echo=FALSE, message=FALSE, warnings=FALSE, results='asis'}
kable(sumTable, format = "markdown")
```
### Visualization of data
`r library(ggplot2)
library(scales)
options(scipen = 999)`
```{r fig.width=8, fig.height=6, echo=FALSE}
ggplot()
```
```{r fig.width=8, fig.height=6, echo=FALSE}
ggplot()
```
In the command line I run
Rscript -e "library(knitr);require(methods);knit(C:/Users/durlij/Desktop/Reports/myFile.Rmd)"
It starts to run, completes the first in-line code chunk, but gets an error on the ggplot.
The error is:
Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection
Calls: knit ... <Anonymous> -> png -> .handleSimpleError -> h -> cat -> file
In addition: Warning messages:
1: package 'scales' was built under R version 3.1.3
2: In png(..., res = dpi, units = "in") :
unable to open file 'figure/unnamed-chunk-2-1.png' for writing
3: In png(..., res = dpi, units = "in") : opening device failed
4: In file(file, ifelse(append, "a", "w")) :
cannot open file 'rmdRun.md': Permission denied
The whole command line echo is:
Warning message:
package 'knitr' was built under R version 3.1.3
Loading required package: methods
processing file: C:/Users/durlij/Desktop/Reports/myFile.Rmd
|..... | 8%
inline R code fragments
|.......... | 15%
label: unnamed-chunk-1 (with options)
List of 5
$ error : logi FALSE
$ echo : logi FALSE
$ message : logi FALSE
$ warnings: logi FALSE
$ results : chr "asis"
|............... | 23%
inline R code fragments
|.................... | 31%
label: unnamed-chunk-2 (with options)
List of 3
$ fig.width : num 8
$ fig.height: num 6
$ echo : logi FALSE
Error in file(file, ifelse(append, "a", "w")) :
cannot open the connection
Calls: knit ... <Anonymous> -> png -> .handleSimpleError -> h -> cat -> file
In addition: Warning messages:
1: package 'scales' was built under R version 3.1.3
2: In png(..., res = dpi, units = "in") :
unable to open file 'figure/unnamed-chunk-2-1.png' for writing
3: In png(..., res = dpi, units = "in") : opening device failed
4: In file(file, ifelse(append, "a", "w")) :
cannot open file 'rmdRun.md': Permission denied
Execution halted