Learn R Programming

jrc (version 0.2.1)

sendData: Send data to the server

Description

Sends a variable to the server, where it is assigned to the variable with a specified name. A JavaScript function jrc.sendData(variableName, variable) can send data back from the server to the current R session. If variable name hasn't been previously added to the list of the allowed variables, attempt to assign it from the server will require manual authorization in the R session.

Usage

sendData(variableName, variable, keepAsVector = FALSE, rowwise = TRUE)

Arguments

variableName

Name that the variable will have on the server.

variable

Variable to send.

keepAsVector

If TRUE, variables with length 1 will be saved as arrays on the server, otherwise they will be converted to atomic types.

rowwise

If TRUE, matrices and data.frames will be transformed into JavaScript Objects or Arrays rowwise (e.g. a matrix will become an Array of its rows).

See Also

authorize, allowVariables, sendCommand, callFunction, sendHTML, openPage.

Examples

Run this code
# NOT RUN {
openPage()
x <- 1:100
sendData("x", x)
sendCommand("console.log(x);")
sendCommand("jrc.sendData('x', x.filter(function(e) {return e % 2 == 0}))")
closePage()
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab