On May 10, 2012, at 7:01 PM, Carl pfisterer <[email protected]> wrote:
> I am a web development novice so there is no particular reason it has to be > perl other than that is what I started with. Seemed like an easy way to > interface with MySQL and allowed me to execute R scripts as well. I have > figured out one way to execute run() from within perl but it is not elegant, > it redirects to the new page entirely instead of showing the plot inline. > > my $url = > "http://localhost/cgi-bin/R/carls_test?Projects=$Projects&Species=$Species&Year=$Year&Normalize=$normalize&Lag=$lag"; > print "<META HTTP-EQUIV=refresh CONTENT=\"0;URL=$url\">\n\n"; > Even easier is print "Location: $url\n\n"; but make sure you do NOT print Content-type before that. > I also tried > my $url = > "http://localhost/cgi-bin/R/carls_test?Projects=$Projects&Species=$Species&Year=$Year&Normalize=$normalize&Lag=$lag"; > my $content = get $url; > die "Couldn't get $url" unless defined $content; > print $content; > > This would display the data values and tables inline, but not the > images(image not found box). Clearly, since all relative paths will be off as you are serving this from a different URL > It seems I can't draw to a png device from within run() You should use Cairo instead. Cheers, Simon > so my best/easiest method at the moment is redirecting to the new page. So > far, it seems to take 1/2 to 2/3 the time to create the plots than starting a > new instance of R each time. That is pretty good time savings! > > -Carl > > From: Simon Urbanek <[email protected]> > To: Carl pfisterer <[email protected]> > Cc: "[email protected]" <[email protected]> > Sent: Monday, May 7, 2012 3:57 PM > Subject: Re: [R-SIG-Mac] FastRWeb Questions > > > On May 7, 2012, at 3:49 PM, Carl pfisterer wrote: > > > Thanks Simon, that helps a lot. With respect to my last question, I have a > > cgi script that gets user input from a form, then plots the data in R. > > What I would like to do is to call run(...) from within the cgi script when > > the user clicks submit. > > > > Well, you could get rid of the perl part to start with - FastRWeb > automatically maps form entries into run() arguments so you should not need > perl at all to process forms. If you still have some logic in perl that you > don't want to push to R then your options may be thin -- you could run Rcgi > from perl, use AJAX (from a page you generate with perl) or connect to Rserve > directly, but I don't have an Rserve perl client, so you'd have to look > elsewhere (maybe misappropriating the C++ client or something like that ... > however, it should be fairly easy to write perl client for this purpose since > you're only interested in strings) > > Cheers, > Simon > > > > -Carl > > > > From: Simon Urbanek <[email protected]> > > To: Carl pfisterer <[email protected]> > > Cc: "[email protected]" <[email protected]> > > Sent: Monday, May 7, 2012 9:20 AM > > Subject: Re: [R-SIG-Mac] FastRWeb Questions > > > > Carl, > > > > On May 7, 2012, at 1:04 PM, Carl pfisterer wrote: > > > > > I have gotten FastRWeb working on Mac OS X 10.5 but I have a few of > > > questions. Is it possible to send more than one argument to run(...)? > > > > Yes > > > > > > > How would I parse a range sent as an argument (i.e. run(x=1:20))? > > > > typically > > > > http://.../R?x1=1&x2=20 > > > > run <- function(x1, x2, ...) { > > x <- seq(as.integer(x1), as.integer(x2)) > > > > In theory you could use > > > > http://.../R?x=1:20 > > > > run <- function(x, ...) { > > x <- eval(parse(text=x)) > > > > but I would not recommend that since it would allow users to inject > > arbitrary code which is not good for the security ... > > > > > > > Finally, what is the syntax to call the R script from within a PERL > > > script? > > > > What do you mean? R scripts are to be run from R, not perl... You could > > simply run the Rcgi binary, but I'm not sure where you are heading with > > this ... > > > > > > > I have read Simon's paper at: > > > http://urbanek.info/research/pub/urbanek-iasc08.pdf and it has helped, > > > but I didn't see these particular items addressed. FastRWeb looks very > > > promising, my current implementation initializes R each time and is a bit > > > slow, I am hopeful this will speed things up a lot. > > > > > > > It certainly will a there is no startup delay. > > > > Cheers, > > Simon > > > > > > > > > > > [[alternative HTML version deleted]] _______________________________________________ R-SIG-Mac mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-mac
