Opal is connected with one or more R servers. 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 servers. 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, specifying that the R server session must be created with the “default” profile, i.e. in the “default” R servers cluster (note that the profile parameter is optional):
Assign a Opal table to a data.frame (if user has permission to see values of the Opal table):
In place of a standard data.frame, Opal can assign data into a tibble:
Resource objects can be assigned to the R server session:
An R expression can also be assigned to a symbol (use
quote()
to not interpret the expression in the client side
R session). As an example assign a function body:
List the R symbols that lives in the remote R session:
R expressions can be executed on the server side:
# column names
opal.execute(o, script = "names(tbl)")
# get variable description from column attributes
opal.execute(o, script = "attributes(tbl$GENDER)")
# coerce resource to a data.frame and plot histogram of one column
plot(opal.execute(o, script = "hist(as.data.frame(rsrc)$LAB_HDL)"))
# execute the custom function
opal.execute(o, script = "hello('friends')")
The remote data can be downloaded into the client side R session:
To execute more complex R code, use a local source file:
Files can be written from the Opal file system to the R server session folder:
Similarly, files can be read from the R server session folder into the Opal file system:
The image of the remote R session can be saved in a workspace (to be restored at login time):