runR {shinylight}R Documentation

Returns a function that runs an R command

Description

If you set this as a part of your interface, like: runR=shinylight::runR(c("+", "plot", "c", "x", "y")) then you can call it from Javascript like this:

rrpc.call("runR", {
 Rcommand:"2+2"
}, function(x) {console.log(x);});
rrpc.call("runR", {
 Rcommand:"y<-c(2,0,1);plot(c(1,2,3),y);y",
 'rrpc.resultformat': {
   type: 'png',
   width: 200,
   height: 300,
 }
}, function(x) {img.setAttribute('src', x.plot[0])});

Usage

runR(symbolList)

Arguments

symbolList

A list of permitted symbols in the R command

Value

A function that can be passed as one of the elements of slServer's interface argument.

Examples

server <- slServer(
  port = 50050,
  interface = list(
    run_the_users_r_code = runR(
      list("c", "$", "list", "+", "-", "/", "*", "sqrt")
    )
  )
)
# ...
slStop(server)

[Package shinylight version 1.2 Index]