如题,在使用Windows R的过程中不少遇到下面类似的错误。这是因为R无法对系统默认的临时目录进行读写操作。
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/ADMINI~1/AppData/Local/Temp/Rtmpe2OFDK/b93d7aaea7d247f9aec596ec8fbbc7db.png", :
无法打开'C:/Users/ADMINI~1/AppData/Local/Temp/Rtmpe2OFDK/b93d7aaea7d247f9aec596ec8fbbc7db.png'文本写入
2: In grDevices:::png("C:/Users/ADMINI~1/AppData/Local/Temp/Rtmpe2OFDK/b93d7aaea7d247f9aec596ec8fbbc7db.png", :
opening device failed
我们自己为R创建一个临时目录,这样就跟系统的临时目录没关系了~~
> dir.create("C:/Rtmp")
> cat("TMPDIR = C:\\\\Rtmp", file = "~/.Renviron", sep = "\n")
重启R即可。
网友评论