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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With