Skip to content
Olli Niemitalo (HAMK) edited this page Apr 10, 2026 · 5 revisions

Rprebasso for WebR

To build the Rprebasso R package for WebR, in order to run it in browser (client side) using WebAssembly (Wasm), we use addnab/docker-run-action to run rwasm::add_pkg() inside the ghcr.io/r-wasm/webr:main Docker image. This publishes in GitHub Pages a CRAN-like repository for WebR packages, containing just Rprebasso. This required enabling GitHub Pages in the repo settings: GitHub pages -> Build and deployment -> Source: GitHub Actions.

Using Rprebasso with WebR

To install Rprebasso in interactive WebR:

install.packages(
  'Rprebasso', 
  repos = c(
    'https://hamk-uas.github.io/Rprebasso-WebR/',
    'https://repo.r-wasm.org/'
  )
)
library(Rprebasso)

or to use it from client-side JavaScript:

const webR = await import('https://webr.r-wasm.org/latest/webr.mjs').then(
  async ({ WebR }) => {
    const webR = new WebR();
    await webR.init();
    return webR;
  }
);

await webR.installPackages(packages="Rprebasso", {repos: ['https://hamk-uas.github.io/Rprebasso-WebR/', 'https://repo.r-wasm.org/']});
await webR.evalR('library(Rprebasso)');

The function prebas can then be called using R syntax:

await webR.evalR('prebas(ARGUMENTS)');

or directly from JavaScript:

prebas = await webR.evalR('prebas');
prebas(ARGUMENTS)

replacing ARGUMENTS with your own arguments.

Clone this wiki locally