My guess is that R doesn't have a display so it's trying to make
it's
default Rplots.pdf instead. What if you generate a .eps in an
appropriate location (that's writeable by your server)? e.g.:
postscript('/Library/WebServer/Documents/gsa/test.eps',horizontal=FALSE)
plot(swiss$Catholic, swiss$Examination)
dev.off()
You'll probably want to switch postscript() to png() for web stuff but
sometimes that can have funny X11/display requirements so probably
better to try the postscript first then go from there.
Scott
Scott Sherrill-Mix
Department of Microbiology
University of Pennsylvania
402B Johnson Pavilion
3610 Hamilton Walk
Philadelphia, PA 19104-6076
On Tue, Aug 11, 2009 at 6:18 AM, Michael
Richardson<mrich at u.washington.edu> wrote:> Greetings,
>
> I'm trying to debug a simple two-line plot routine in R called test.R:
>
> ? cor(swiss)
> ? plot(swiss$Catholic, swiss$Examination)
>
> These commands work fine when typed into R. ?They also work fine when I
> invoke this routine by the following line into my terminal:
>
> R --slave < /Library/WebServer/Documents/gsa/test.R
>
> My ultimate goal is to send data to this R routine via a web interface
> mediated by Ruby. ?However, I've run into a wall there -- the commands
that
> work fine when typed directly into the command line, fail when sent via
> Ruby.
>
> 1. ?I start with a simple HTML page that calls a simple two-line Ruby CGI
> program (gsa.cgi):
>
> ? #!/usr/bin/ruby
> ? system("R --slave <
/Library/WebServer/Documents/gsa/test.R")
>
> 2. ?However, when I hit the submit button on the HTML page, I get the
> following error messages on my Apache 2 server log:
>
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] Error in function (file
> ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"), ?:
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] ? unable to start device
pdf
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] Calls: plot ...
plot.default
> -> plot.new -> <Anonymous> -> .External
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] In addition: Warning
> message:
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] In function (file >
ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"), ?:
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] ? cannot open 'pdf'
file
> argument 'Rplots.pdf'
> [Tue Aug 11 01:22:41 2009] [error] [client ::1] Execution halted
>
> 3. ?If I comment out the line in test.R with the plot command, all works
> fine.
>
> FWIW, I'm running this on a MacBook Pro OS X 10.5.8 with Ruby 1.8.7
>
> Any assistance would be gratefully accepted.
>
> Regards,
>
> Michael L. Richardson, M.D.
> University of Washington Radiology
>
> ______________________________________________
> 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.
>