R can't start PNG device - features () has TRUE for PNG?

I work with R script in a wider pipeline, which does not seem to work with some versions of Rscript, but with others. The call failed due to the inability to connect to X11, which is understandable because it is on the server. But is my local Rscript installation capable of handling this?

My local installation is version 3.0.1, while other users reporting this problem are at 3.0.2.

Here is a simple test case: first the .R file:

#!/usr/bin/env Rscript capabilities() png("abc") dev.off() 

Run with my local env:

 -bash-4.1$ ./test.R 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 FALSE TRUE TRUE FALSE TRUE null device 1 

When installing other users, Rscript tries to use:

  jpeg png tiff tcltk X11 aqua http/ftp sockets TRUE TRUE FALSE TRUE FALSE FALSE TRUE TRUE libxml fifo cledit iconv NLS profmem cairo TRUE TRUE FALSE TRUE TRUE FALSE TRUE Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, : unable to start device PNG Calls: png In addition: Warning message: In png("abc") : unable to open connection to X11 display '' Execution halted 
+8
r
source share
4 answers

In case anyone finds this on google, the solution will be

 png("abc", type="cairo") 
+14
source share

You can run it in the R command

 options(bitmapType='cairo') png("xzvf.png") plot(z~x) dev.off() 
+5
source share

Try Rscript call Rscript with

  xvfb-run 

or even

  xvfb-run --server-args="-screen 0 1024x768x24" 

like png, if memory is used, x11 font information is used. The x11 virtual server, starting with xvfb-run , provides it, so it helps with headless settings, cron jobs, etc. Pp

+3
source share

I had the same problem on a new install of Ubuntu 14.04.

Just installing xvfb-run solved the problem without even starting it before starting R.

0
source share

All Articles