I have an existing Javascript/HTML Application. I wanted to use power of R Programming
's scientific computing and graphics.
My aim is to,
How to achieve this,
Should I run R continuously, use something like web sockets
and connect to R? If doing How to pass R scripts to execute and get the output pack?
There is Rserve. There are some nodeJS
implementation for Rserve
. But problem with this is, each line of code should be passed through the evaluate
commands. Even though if I do so, how to handle the graph output?
I explored a bit of openCPU. If using openCPU R package, R should be continuously Running with opencpu
library and each we start R and openCPU, it starts with different port number. And if i close the R session, opencpu
server also terminates.
If I install standalone opencpu
server in my machine, how to use R with this? I've installed openCPU standalone server and a kind of stuck after that.
How should I proceed, What should I do to accomplish my task. I'm like a kind of don't know which direction to go. Please throw some light on this. I'm sure most people would need this.
I have worked with shiny
, but in this case, I can not make use of it. Need to connect R from external Web Application.
FastRWeb sounds like it would be perfect for your needs. From the documentation:
FastRWeb is an infrastructure that allows any webserver to use R scripts for generating content on the fly, such as web pages or graphics. URLs are mapped to scripts and can have optional arguments that are passed to the R function run from the script. For example http://my.server/cgi-bin/R/foo.png?n=100 would cause FastRWeb to look up a script foo.png.R, source it and call run(n="100"). So for example the script could be as simple as
run <- function(n=10, ...) { p <- WebPlot(800, 600) n <- as.integer(n) plot(rnorm(n), rnorm(n), col=2, pch=19) p }
This can potentially then be called using JavaScript to dynamically load images and display them.
You might also like to think about shiny, though that's more of a complete solution.
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