Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error)

后端 未结 8 1549
渐次进展
渐次进展 2021-01-08 00:32

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 h

相关标签:
8条回答
  • 2021-01-08 00:46

    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.

    0 讨论(0)
  • 2021-01-08 00:51

    Reinstall the package ggplot2 (install.packages"ggplot2") and invoke the library. It must work then

    0 讨论(0)
  • 2021-01-08 00:53

    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.

    0 讨论(0)
  • 2021-01-08 00:53

    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

    0 讨论(0)
  • 2021-01-08 01:01

    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:

    1. sudo service rstudio-server stop
    2. remove all rstudio related files (sudo find / -name "rstudio" | xargs sudo rm -r)
    3. re-install R studio server: http://www.rstudio.com/ide/download/server
    0 讨论(0)
  • 2021-01-08 01:03

    Thank goodness, I just exited Rstudio and relaunched and the problem went away

    0 讨论(0)
提交回复
热议问题