我是一位经验丰富的 R 和 knitr 用户,自 2012 年以来一直在使用这些,所以我是解决问题的老手,但这让我很难过。其实这个问题很关键。
这是可以正常工作的代码:
<<configure, eval=TRUE>>=
rm(list = ls())
library(knitr)
library(ggplot2)
library(tidyr)
@
这是导致问题的代码:
<<configure, eval=TRUE, dev='png', fig.width=4, fig.height=4>>=
rm(list = ls())
library(knitr)
library(ggplot2)
library(tidyr)
@
这是错误消息:
> knit2pdf("template.Rnw")
processing file: template.Rnw
|
| | 0%
|
|............. | 20%
ordinary text without R code
|
|.......................... | 40%
label: configure (with options)
List of 4
$ eval : logi TRUE
$ dev : chr "png"
$ fig.width : num 4
$ fig.height: num 4
Quitting from lines 43-47 (template.Rnw)
Error in (function (filename = "Rplot%03d.png", width = 480, height = 480, :
unable to start png() device
In addition: Warning messages:
1: In (function (filename = "Rplot%03d.png", width = 480, height = 480, :
unable to open file 'C:\Users\ccc31\AppData\Local\Temp\RtmpSwTCKI\file8e94649b2b62' for writing
2: In (function (filename = "Rplot%03d.png", width = 480, height = 480, :
opening device failed
我已经在这个文件上工作了至少六个星期,没有任何问题,但现在它莫名其妙地失败了。自从我上次运行它以来,有两件事发生了变化。(1) 我的 McAfee Total Protection 已更新。(2) 我的 Windows 10 操作系统安装了更新。(3) 其他东西可能已经改变,但我不知道它是什么。
我正在使用控制台运行 R x64 3.5.1 并运行上面显示的命令。这是我正在进行的一个关键项目,我只有几天的时间来完成它,所以任何帮助都将不胜感激。谢谢你。