繁体   English   中英

R包编织程序无法打开png()设备

[英]R package knitr unable to open png() device

我是一位经验丰富的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,并运行上面显示的命令。 这是我正在研究的一个关键项目,我只有几天的时间才能完成它,因此任何帮助将不胜感激。 谢谢。

这不是解决方案,而是“解决方案”。 (1)我保存了历史文件后关闭了R控制台,以防万一。 (2)我删除了.RData文件。 (3)我重启了机器。 (4)我打开了一个新的R控制台,导航到我的项目目录,并运行了我的脚本。

一切恢复正常。 哇! 不过,我想知道错误的来源,但我对它的工作感到满意。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM