Opal R Session API

Yannick Marcon

2019-08-15

Opal is connected with a R server. Each Opal user having the appropriate permissions can create a R session on the server side through Opal. See the R Server documentation page that explains the relationship beteen Opal and the R server. The Opal R package exposes data management related functions:

Note that these functions do create a R session on the server side.

Setup the connection with Opal:

library(opalr)
o <- opal.login("administrator", "password", "https://opal-demo.obiba.org")

Assign a Opal table to a data.frame (if user has permission to see values of the Opal table):

opal.assign.table(o, symbol = "df", value = "datashield.CNSIM1")

In place of a standard data.frame, Opal can assign data into a tibble which has the advantage of containing the data dictionary:

opal.assign.table.tibble(o, symbol = "tbl", value = "datashield.CNSIM1")

List the R symbols that lives in the remote R session:

opal.symbols(o)

R expressions can be executed on the server side:

opal.execute(o, script = "names(tbl)")

The remote data can be downloaded into the client side R session:

tbl <- opal.execute(o, script = "tbl")

The image of the remote R session can be saved in a workspace (to be restored at login time):

opal.workspace_save(o, save="cnsim1")
opal.workspaces(o)

Good practice is to free server resources by sending a logout request:

opal.logout(o)