Error in R: Unable to open connection to X11

command linex11

I just set up a fedora distribution on my computer and am slowly trying to learn how to work from the command line. I was testing R which went fine, except for some reason when I tried again I suddenly seem to be unable to draw plots. I get the error:

> x = 1:5
> y = x^2
> plot(x,y)
No protocol specified
Error in X11(d$display, d$width, d$height, d$pointsize, d$gamma, d$colortype,  : 
  unable to start device X11cairo
In addition: Warning message:
In function (display = "", width, height, pointsize, gamma, bg,  :
  unable to open connection to X11 display ''

and when I check the capabilities I see that X11 is FALSE:

> capabilities()
No protocol specified
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE     TRUE     TRUE    FALSE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE     TRUE 

Although I know nothing about whether those are connected or not it seems X11 should be on?

Everywhere I searched for this people seemed to have this problem when working over an ssh connection (I haven't yet taken a look at what that is exactly :$).

I hope someone who knows what this problem is about could be so nice to explain the problem to me and suggest a solution.

Best Answer

There are many threads elsewhere related to Cairo package.

One of them mentions the change in X11 type but most of them state that R doesn't know what the display is and suggest doing:

Sys.setenv("DISPLAY"=":0.0")

or, on older systems,

Sys.putenv("DISPLAY"=":0.0")
Related Question