[R] jpeg in batch mode

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 21 22:29:47 CET 2008

On Thu, 21 Feb 2008, Elizabeth Purdom wrote:

> Hello,
> I am running some commands in batch on a server that I SSH into; some of
> the commands call jpeg(). If I continue to stay signed on (with my
> xwindows working on my machine) then the jpeg() command works (with a
> single caveat, below). If I leave it and sign off (with a nohup command
> in front of my BATCH) then jpeg gives me an error like this:
>  Error in X11(paste("jpeg::", quality, ":", filename, sep = ""), width,  :
>         unable to start device JPEG
> In addition: Warning message:
> could not open JPEG file xyz.jpeg
> I don't have this problem with pdf(); but the images I want to draw are
> really massive in terms of the number of points/images so they take
> forever to open in adobe (as well as being HUGE) so I'd like them in
> jpeg. Can I get around this somehow? I saw other people posted similar
> problems, but saw no solutions.

Well, this is documented and there are solutions even on the jpeg() help 
page and mamy more in the archives.  Basically

1) Use a Xvfb X server
2) Use bitmap()
3) Use an alternative such as GDD or Cairo (but for me those do a poor job 
on symbol fonts).

The good news is that R 2.7.0 will have a better solution, producing JPEGs 
without using X11.

> R-2.6.0, GNU/Linux
> Thanks,
> Elizabeth
> My caveat from above about the jpeg working as long as I'm signed on:
> one time I got the mysterious error:
> >
> jpeg("~/batch5Effect/ProbPbsets_summaryHeatmaps%03d.jpeg",height=1200,width=800)
> Error in jpeg("~/batch5Effect/ProbPbsets_summaryHeatmaps%03d.jpeg",
> height = 1200,  :
>   X11 fatal IO error: please save work and shut down R
> Even though it had just correctly done this same basic command a few
> lines back. I redid it (without changing anything that I was aware of)
> and it worked fine. So I don't think it's related.

That's an X11 problem, not an R problem.

> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list