Reputation: 181
I am trying to plot using Rstudio. But when I do, plot(cars)
which is the basic function, I am getting an Graphics Error in R
.
Here is what I have done :
> plot(cars)
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
Please guide me through.
Upvotes: 18
Views: 32560
Reputation: 5398
Solution for error:
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In R Studio, navigate to Tools, Global, Graphics (top middle), set Backend to AGG
*, Apply, Ok
*Depending on your system/installation, you may have other other options in the drop down. Ex. AGG
, Cairo
, Cairo PNG
.
AGG is a package which provides graphic devices for R based on the AGG library developed by the late Maxim Shemanarev. AGG provides both higher performance and higher quality than the standard raster devices provided by grDevices. You might need to install AGG. Compatible with R Studio since v1.4.
Upvotes: 7
Reputation: 2431
I meet this today, reindatall Rstudio still can't solve. finally installed textshaping install.packages('textshaping'). It's ok now
Upvotes: 0
Reputation: 1577
Thank goodness, I just exited Rstudio and relaunched and the problem went away
Upvotes: 5
Reputation: 11
Reinstall the package ggplot2 (install.packages"ggplot2") and invoke the library. It must work then
Upvotes: 0
Reputation: 63
I had the same problem (even though I had been using the same installation for over a year without this problem). I just needed to restart the computer and everything was good again. :D
Upvotes: -1
Reputation: 13
I had the same error and am on Ubuntu. I did not install R through sudo apt-get install r-base
but instead downloaded a specific version, unpacked it and installed it manually with:
./configure --with-readline=no --with-x=no --enable-R-shlib
make
sudo make install
I did not have cairograpghics installed, which is apparently important to build 2D graphics with R. So I installed that with:
sudo apt-get install libcairo2-dev
Or find the version for your OS here: https://www.cairographics.org/download/
I then uninstalled R again by simply going into the downloaded R folder that I had previously compiled using the above commands mentioned and typed:
sudo make uninstall
And then I configured and installed the same R version again. That did it. The uninstall and reinstall was important, just installing cairographics didnt work, you have to have it installed before using ./configure
.
Upvotes: -1
Reputation: 1204
Initially, I reinstalled RStudio to the newest version (1.1.442) and, following many advice also the R-base* system (getting to R 3.4.3) using aptitude in the following way:
sudo aptitude reinstall libpangocairo-1.0-0 libpango-1.0-0
sudo aptitude reinstall r-base r-base-core r-base-dev
I used aptitude because it is usually better than apt-get to disentangle intricate dependency trees. Afterwards, when no package was loaded into the environment it was working just fine but any package loading was creating a whole variety of DLL-related errors as follows.
FINAL SOLUTION (NO NEED OF REINSTALL):
The error was showing again as soon as I loaded my self-made library. The real problem is the number of open DLL. If you load too many packages or files you will get to the limit and you will have error messages between maximal number of DLLs reached...
or failed to load cairo DLL
(this error warning) or even lapack routines cannot be loaded
. I had these three error randomly as I loaded my full-of-dependencies-homemade-library.
So I started again looking for a solution. The final one is to allow more DLL and to do so it is enough to set the environmental variable R_MAX_NUM_DLLS
to a higher number (I set it to 500). In order to avoid the hassle of setting it every time you can read ?Startup
documentation and consequently write R_MAX_NUM_DLLS=500
in your Renviron file R-HOME/etc/Renviron.site
. In my case (Ubuntu:16.04 it was /usr/lib/R/etc/Renviron.site
. This fixed smoothly the problem.
Upvotes: 4
Reputation: 24397
I had the following error in a CentOS:7 Docker container when running rstudio-server verify-installation
:
27 Feb 2017 14:17:09 [rsession-rstudio-server] ERROR r error 4 (R code execution error) [errormsg=Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) :
error in running command
]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::<unnamed>::evaluateExpressionsUnsafe(SEXPREC*, SEXPREC*, SEXPREC**, rstudio::r::sexp::Protect*, rstudio::r::exec::<unnamed>::EvalType) /root/rstudio/src/cpp/r/RExec.cpp:159; LOGGED FROM: rstudio::core::FilePath rstudio::session::module_context::findProgram(const std::string&) /root/rstudio/src/cpp/session/SessionModuleContext.cpp:879
27 Feb 2017 14:17:09 [rsession-rstudio-server] ERROR r error 4 (R code execution error) [errormsg=Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) :
error in running command
]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::<unnamed>::evaluateExpressionsUnsafe(SEXPREC*, SEXPREC*, SEXPREC**, rstudio::r::sexp::Protect*, rstudio::r::exec::<unnamed>::EvalType) /root/rstudio/src/cpp/r/RExec.cpp:159; LOGGED FROM: rstudio::core::FilePath rstudio::session::module_context::findProgram(const std::string&) /root/rstudio/src/cpp/session/SessionModuleContext.cpp:879
I fixed it by installing which
command: yum install which
Upvotes: -1
Reputation: 13914
I had the same issue and found James Mao's answer helpful, but I wanted to avoid reinstalling R so that I would not have to also reinstall all of my R packages. I was able to fix the issue by reinstalling RStudio without reinstalling R, which makes sense because the error is with RStudio, not R itself. Here are the instructions:
sudo service rstudio-server stop
sudo find / -name "rstudio" | xargs sudo rm -r
)Upvotes: 0
Reputation: 29
Under Ubuntu 13.10 I had the similar issue with rstudio server, tried all different suggestions no work. Finally figured out this way:
sudo service rstudio-server stop
sudo find / -name "rstudio" | xargs sudo rm -r
)sudo apt-get remove r-base-core r-base r-base-dev
sudo find / -name "R" | xargs sudo rm -r
)sudo apt-get install r-base-core r-base r-base-dev
Upvotes: 2