解决从命令行运行Rmarkdown的错误

时间:2015-08-04 15:18:55

标签: r command-line r-markdown rscript

我想从命令行运行Rmarkdown,这将保存HTML输出(如果命令行显示我是否运行的情节,我不在乎,只要结果是保存)。

我的Rmd脚本类似于:

jRate.change(function(){// stuff in here});

在命令行中我运行

---
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()
```

它开始运行,完成第一个内联代码块,但在ggplot上出错。

错误是:

Rscript -e "library(knitr);require(methods);knit(C:/Users/durlij/Desktop/Reports/myFile.Rmd)"

整个命令行回显是:

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

0 个答案:

没有答案
相关问题