I would like to provide the following service on a webpage:
I don't want to run my own computer all the time so a kind of a cloud solution should be employed (I guess?!?).
Do you have any ideas how to accomplish the above ideas?
You may have a look at FastRWeb - it serves R scripts as if they were web pages and supports graphics as well as regular output. It uses Rserve which makes it much faster than any solution that involves starting R (such as R
or Rscript
). It works on any webserver wither via CGI or PHP.
A script to generate a plot would look like:
run <- function(n=100, ...) {
p <- WebPlot(800, 600)
n <- as.integer(n)
plot(rnorm(n), rnorm(n), col=2, pch=19)
p
}
Other solution is RApache which embeds R directly into the apache webserver.
Edit: And also by Jeff there is now Rook that uses the embedded R HTTP server (thanks to Joshua for pointing that one out).
You mentioned running it daily - if you don't need online analysis, you can simply generate html
pages and png
files with R and send them to your webserver - all in an automated script. There are many R package that facilitate HTML output - just search in the CRAN package list for HTML.
Use Rscript
and cat
to print an HTTP response like you would from any CGI-bin. For example, set the content type of the response and then cat
some HTML, or print a PNG, etc:
#!/path/to/Rscript
cat("Content-type: text/html\n\n")
cat("<html>")
cat("<body>")
cat("<p><em>Hello</em>, world!</p>")
v <- round(runif(10)*10, 0) # sample ten random integers from {0..10}
cat("<p>", v, "</p>")
cat("</body>")
cat("</html>")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With