Learn R Programming

Rock R

R implementation of the Rock R server REST API. Allows to interact with a remote R session in a stateful way.

Usage:

library(rockr)

# Make a connection object
conn <- rockr.connect('username', 'passwd', url = 'https://rock-demo.obiba.org')

# Get the status of the R server (admin only)
rockr.status(conn)

# Restart the remote R server (admin only)
rockr.start(conn)

# Open an R session
rockr.open(conn)

# Assign a R expression to a R symbol
rockr.assign(conn, 'x', 123)
rockr.assign(conn, 'y', 'hello')
rockr.assign(conn, 'z', quote(tibble::tribble(
  ~colA, ~colB,
  'a',   1,
  'b',   2,
  'c',   3
)))

# Evaluate a R expression
rockr.eval(conn, quote(x))
rockr.eval(conn, quote(ls()))
rockr.eval(conn, call("ls"))

# Asynchronous assignment and evaluation
cmd <- rockr.eval(conn, quote(z), async = TRUE)
rockr.command_result(conn, cmd$id, wait = TRUE)

# File upload and download
rockr.file_upload(conn, source = "foo", destination = "/somedir/bar")
rockr.file_download(conn, source = "/somedir/bar", destination = "foo2")

# Terminate the remote R session
rockr.close(conn)

Copy Link

Version

Install

install.packages('rockr')

Monthly Downloads

213

Version

1.0.0

License

MIT + file LICENSE

Maintainer

Yannick Marcon

Last Published

March 12th, 2021

Functions in rockr (1.0.0)

rockr.close

Close the R session
rockr.command_result

Get result of an asynchronous command
rockr.commands

List the asynchronous commands
rockr.command

Get an asynchronous command
rockr.commands_rm

Remove all asynchronous commands
rockr.command_rm

Remove an asynchronous command
.handleResponse

Default request response handler.
rockr.file_upload

Upload a file
rockr.file_download

Download a file
.url

Utility method to build urls. Concatenates all arguments and adds a '/' separator between each element
rockr.packages

List of the packages in the R server
rockr.packages_datashield

List of the settings of the DataSHIELD packages
rockr.assign

Assign an R expression or data
rockr.put

Generic REST resource update.
.verbose

Verbose flag
.is.verbose

Verbose option
.handleError

Handle error response
rockr.packages_rm

Remove some packages from the R server
rockr.get

Generic REST resource getter.
rockr.assign.data

Assign an R object
rockr.eval

Evaluate a R script
rockr.package_install

Install a package in the R server
rockr.log

Log of the R server
rockr.package_rm

Remove a package from the R server
rockr.version

Version of the R server
rockr.post

Generic REST resource creation.
rockr.start

Start the R server
rockr.eval.source

Evaluate a R file script
rockr.sessions

List of the R sessions
rockr.open

Open an R session
rockr.connect

Rocker connection
rockr.assign.expr

Assign an R expression
rockr.package

Package description from the R server
rockr.delete

Generic REST resource deletion.
rockr.session

Get a R session
rockr.session_switch

Switch R session
rockr.restart

Restart the R server
rockr.status

Status of the R server
rockr.stop

Stop the R server
.is.opened

Check connection is opened, calls stop() if it is not the case.
.getContent

Wrapper of httr::content()
.authorizationHeaderRockr

Constructs the value for the Opal Authorization header
.deparse

Turn expression into character strings.
.authorizationHeaderBearer

Constructs the value for the Bearer Authorization header
.handleAttachment

Handle the file content.
.handleResponseOrCallback

Process response with default handler or the provided one
.handleContent

Handle the response content, unserialize when necessary.