Skip to contents

The rw package provides an R interface to run R code in a sandboxed WebAssembly (Wasm) environment via Node.js and webR. The package wraps the rw CLI tool, enabling secure evaluation of untrusted R code isolated from the host system.

Main R functions

rw_do_call()

Call an R function with argument in webR and return the result. Works similarly to do.call().

Low-level functions for calling 'rw'

rw()

Run R code with full control over prologue/epilogue, bindings, and sandboxing

rw_source()

Source R scripts

Utility functions

rw_r_libs_user()

Get the R package library path for webR

rw_version(), rw_webr_version(), rw_r_version()

Version information

rw_config()

Get detailed webR configuration

rw_available()

Check if the rw CLI is available

Sandboxing model

The security model uses webR's isolation with controlled host directory access:

  • Main code: Runs without access to the stage directory

  • Prologue/Epilogue code: Has access to stage for data transfer

  • binds: Host directories mounted and available to all phases

  • r_libs: Mounted R package library available to all phases

Environment variables

RW_BIN

Path to the rw CLI executable

RW_R_LIBS_USER

Default R library path for webR

RW_STAGE

Default staging directory

Author

Maintainer: Henrik Bengtsson henrikb@braju.com [copyright holder]

Other contributors:

  • R Consortium (ROR) [funder]