RDOM.Rcall: Call R from a web browser.

Description Details Author(s) See Also

Description

Call an R function from javascript code in a web page.

Details

This is not an R function; it is a javascript function that is available within the web page that R is connected to. It can be used to call an R function from the web page, e.g., in response to a user event, and optionally run a callback function in the web page when the R function returns a result.

The RDOM.Rcall function takes four arguments:

A typical usage might look like this (to call an R function when a button is clicked on the web page):

1
<button onclick='RDOM.Rcall("fnname", this, [ "HTML" ], null)'>

The R function that is called by RDOM.Rcall is provided with a variable number of arguments equal to the number of DOM nodes times the number of node types (with the number of types changing fastest). In the example above, the R function would receive only one argument.

It is also possible to pass raw javascript values in the second argument, instead of DOM nodes. In this case, the type argument should be one of "string", "number", "boolean", or "JSON" (for more complex sets of values).

The return value of the R function (if any) is converted to a JSON object and passed to the callback function specified in the call to RDOM.Rcall).

Author(s)

Paul Murrell

See Also

htmlPage


pmur002/DOM documentation built on May 25, 2019, 10:20 a.m.