Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X11 is not available in R

Tags:

r

x11

Problem

I'm following along some code and get an error related to X11. To recreate my error, I ran x11() and got the following:

> x11()
Error in x11() : X11 is not available

I have definitely plotted things in R that loaded the XQuartz program to display.

What I tried

  • I did ?x11() and saw that it is from the {grDevices} package. I loaded that library, tried again, but got the same error. I read that X11 is related to XQuartz.
  • I re-installed XQuartz 2.7.8. I have R 3.2.3 and am running OSX El Capitan version 10.11.4 (15E65). I restarted twice after re-installing.
  • install.packages("Cairo")

    > x11( width=3, height=3) Error in x11(width = 3, height = 3) : X11 is not available

    > Sys.getenv("DISPLAY") [1] "/private/tmp/com.apple.launchd.F1bsaVCA43/org.macosforge.xquartz:0"

    > capabilities() jpeg png tiff tcltk X11 aqua http/ftp TRUE TRUE TRUE TRUE FALSE TRUE TRUE sockets libxml fifo cledit iconv NLS profmem TRUE TRUE TRUE TRUE TRUE TRUE TRUE cairo ICU long.double libcurl TRUE TRUE TRUE TRUE

- Google researching

I Googled using my error message and searched through the first two pages of my results but didn't find any solutions that worked. Based on my perusal of solutions, I provided my system information above since it seems to be relevant somehow. Any ideas/solutions/new leads would be appreciated.

like image 840
user2205916 Avatar asked Apr 24 '16 04:04

user2205916


3 Answers

You will need to download the R from cran (not Homebrew). After so doing the X11 will show up in capabilities() :

enter image description here

like image 110
WestCoastProjects Avatar answered Sep 28 '22 14:09

WestCoastProjects


The XQuartz package is the Mac X11 and your version is the current one. I'm wondering if you need to reboot after installation although I don't claim to know that. (And it might not hurt to repair permissions.) On my Mac (running 3.3.0 on El Cap) I need to set width and height (in inches, not pixels or points);

 x11( width=3, height=3)

What do you get with:

Sys.getenv("DISPLAY")

Might be something along the lines of:

"/private/tmp/com.apple.launchd.KImNTikz8K/org.macosforge.xquartz:0"

Also run:

capabilities()
like image 4
IRTFM Avatar answered Nov 10 '22 23:11

IRTFM


I had this same issue and installing R separately from Rstudio fixed it. You can download it from here and verify x11 is working using x11()

like image 1
timxor Avatar answered Nov 10 '22 21:11

timxor