简体   繁体   中英

Rstudio won't produce plots: Shadow graphics device error: r error 4 (R code execution error)

I've seen this error reported several times but there's never been a solution. I'm using Rstudio for desktop in a Windows 10. I'm not able to produce plots in Rstudio. Plots in R command line work perfectly; in Rstudio if I open a device like in png("myplot.png"); plot(1); dev.off() png("myplot.png"); plot(1); dev.off() png("myplot.png"); plot(1); dev.off() , that works perfectly.

But if I just want to produce a plot in Rstudio (like plot(1) for example), I get the following error:

Error in plot.new() : 
 Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png", :
 unable to open file 'C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png' for writing
2: In grDevices:::png("C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png", :
 opening device failed
3: In grDevices:::png("C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png", :
 unable to open file 'C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png' for writing
4: In grDevices:::png("C:/Users/marco/AppData/Local/Temp/RtmpgfCSkE/c79b28dca0464804b619980ea7a4d95e.png", :
 opening device failed

I tried unistalling RStudio and R, cleaning the registry, and installing again but still the same. This happened after installing R and Rstudio in a new machine. Never had this problem with Rstudio at Windows 10 before.

Any help would be highly appreciated, I can't find any useful hints anywhere.

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] tools_3.3.1
> capabilities()
 jpeg png tiff tcltk X11 aqua http/ftp sockets libxml fifo cledit iconv NLS profmem cairo ICU 
 TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE 
long.double libcurl 
 TRUE TRUE 

你可以使用包来解决情节问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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