[R] Creating images without X11

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sat Mar 13 23:17:26 CET 2010


On Sat, Mar 13, 2010 at 4:27 PM, Jillian E Kozyra <jillyh0 at gmail.com> wrote:
> Dear Colleagues,
>
> We are attempting to create trees using R with our Ruby on Rails
> application. However, we are running into a problem involving the
> creation of the graphic. We would like them to be in either jpg or png
> format so that users can save, but due to a lack of control over our
> sever we are unable to start X11 server. Is there a way to create
> these images without using X11 server?
>

 Not sure what version of R you are using, but the png() device hasn't
needed an X11 server since way back when. Watch:

$ export -n DISPLAY
$ R
 > png()
 > plot(1:10)
 > dev.off()
 > q()

then I have a very fine Rplot001.png file.

 Now it may be that you can't compile PNG support without X11 being
there at compile time, but if you can compile R on a workstation with
X11 support then that R should work find on your server to produce
pngs even without X11 support there and then.

 jpeg() device works the same - X11 not needed at runtime.

 What makes you think it's lack of X11 that is making png or jpeg
devices fail? Run the capabilities() function and see if your R has
png and jpeg support - my suspicion is that you've compiled it on the
server with no X11 headers. It doesn't need a server at runtime.

Barry



More information about the R-help mailing list