webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.

https://github.com/r-wasm/webr

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.8%) to scientific vocabulary

Keywords

emscripten r wasm webassembly

Keywords from Contributors

literate-programming pandoc rmarkdown tidy-data tidyverse
Last synced: 6 months ago · JSON representation ·

Repository

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.

Basic Info
Statistics
  • Stars: 965
  • Watchers: 25
  • Forks: 78
  • Open Issues: 76
  • Releases: 19
Topics
emscripten r wasm webassembly
Created about 4 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License Code of conduct Citation

README.md

Build, test and deploy webR codecov

WebR - R in the Browser

This project aims to compile the statistical language R (https://www.r-project.org/) into WebAssembly for use with a browser, via Emscripten (https://emscripten.org/). The repo includes patches to R's source code so that it can work in the browser environment provided by Emscripten and also includes a web-based IDE through the use of xterm.js and CodeMirror.

Demo

A demo of the webR IDE can be found at https://webr.sh. Please be patient as the Wasm runtime downloads and executes. R will display a banner message when it is ready to use.

Documentation

Documentation showing how to use webR in your own projects can be found at https://docs.r-wasm.org/webr/latest/

Downloading webR

The webR JavaScript package is available for download through npm and on CDN.

Complete release packages, including R WebAssembly binaries, are available to download for self hosting in the GitHub Releases section.

Docker images containing a pre-built webR development environment can be found in the GitHub Packages section.

Building webR from source

R's source code and supporting libraries are written in both C/C++ and Fortran. Source files can be compiled with either a custom development version of LLVM flang (the default) or with gfortran and Dragonegg (using the --with-dragonegg configure option).

If you are compiling webR using the default toolchain, ensure that you first install the following required prerequisites in your build environment: * Emscripten SDK (>=3.1.35) * cmake * gperf * liblzma * libpcre2 * node (>=17.0.0) * quilt * wget

Build instructions

Clone the repo into a new directory, cd into the directory, then run ./configure && make. You can configure make variables in a ~/.webr-config.mk file.

A dist directory is created which when finished contains the R Wasm files and an index.html file ready to serve the included webR IDE.

WebAssembly libraries

WebR relies on additional libraries compiled for Wasm for both Cairo graphics support and for building R packages that depend on certain system libraries. By default, only a minimal set of libraries are built for use with webR.

If you'd prefer to build all of the available system libraries for Wasm, cd into the libs directory and run make all to build the additional libraries, then finally cd .. and run make clean-webr && make to rebuild webR. R will automatically detect the additional Wasm libraries and integrate Cairo graphics support as part of the build.

Building with Docker

Included in the source repository is a Dockerfile which can be used to setup everything that's required for the webR build environment, including LLVM flang and all supported WebAssembly system libraries.

Pre-built docker images can be found in the GitHub Packages section. To build the docker image and webR from source, cd into the webR source directory then run docker build .

The resulting docker image contains a version of R configured to be built for WebAssembly, and so the image can also be used to build custom R packages for webR.

Building with Nix

If you are using Nix, you can start a development environment by running nix develop. Then you can build as usual, with ./configure && make.

Note that this requires that your Nix installation has support for flakes enabled. The easiest way to do this is to install using the Nix installer from Determinate Systems.

Node and Emscripten versioning

WebR requires compiler and runtime support for WebAssembly.Exception, used internally for R error handling. This requires a version of Emscripten >= 3.1.35 and Node >= 17.0.0, which may be newer than the versions provided by your system package manager. An easy way to install and manage multiple versions of Node and Emscripten is by using nvm and emsdk.

The version of Node currently bundled by emsdk is 16.0.0. When building webR with this version of Node the process will fail with configure logs containing the error

WebAssembly.Tag is not a constructor

If this occurs, a newer version of Node should be installed and the following environment variable set before building webR, instructing Emscripten to use the newer version of Node:

export EM_NODE_JS=$(HOME)/.nvm/versions/node/v20.1.0/bin/node

If you are unsure of the correct path to Node the command which node should print the path in full.

Building on macOS Ventura 13.0+

At the time of writing the version of R used as the base for webR does not build cleanly using the macOS Ventura development SDK. If you are not using the included Dockerfile to build webR, the following extra setup must be done before starting the build process,

  • Install the GNU version of the patch program: e.g. brew install gpatch

Using Dragonegg (Optional)

If you intend to build webR using Dragonegg to handle Fortran sources, older versions of the gcc/gfortran toolchain are required than what is provided by modern operating system repositories. The docker file tools/dragonegg/Dockerfile can be used to setup the required C/C++/Fortran toolchain and development environment for compiling webR with Dragonegg.

Owner

  • Name: R for WebAssembly
  • Login: r-wasm
  • Kind: organization

An organization containing projects and packages related to running the statistical language R with WebAssembly.

Citation (CITATION.cff)

cff-version: 1.2.0
title: "webR: The statistical language R compiled to WebAssembly via
  Emscripten"
message: "If you wish to cite this software, please do so as below."  
type: software
authors:
  - given-names: George William
    family-names: Stagg
    email: george.stagg@posit.co
    affiliation: 'Posit, PBC'
  - given-names: Henry
    family-names: Lionel
    email: lionel@posit.co
    affiliation: 'Posit, PBC'
    orcid: 'https://orcid.org/0000-0002-8143-5908'
  - given-names: Others
repository-code: 'https://github.com/r-wasm/webr'
url: 'https://docs.r-wasm.org/webr/latest/'
license: MIT
commit: 71acd7ce6e7053780fd5bb006d955ce042d27f0d
version: 0.2.2
date-released: '2023-11-16'

GitHub Events

Total
  • Create event: 18
  • Release event: 3
  • Issues event: 65
  • Watch event: 127
  • Delete event: 14
  • Issue comment event: 98
  • Push event: 72
  • Pull request review comment event: 3
  • Pull request review event: 4
  • Pull request event: 34
  • Fork event: 13
Last Year
  • Create event: 18
  • Release event: 3
  • Issues event: 65
  • Watch event: 127
  • Delete event: 14
  • Issue comment event: 98
  • Push event: 72
  • Pull request review comment event: 3
  • Pull request review event: 4
  • Pull request event: 34
  • Fork event: 13

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 984
  • Total Committers: 21
  • Avg Commits per committer: 46.857
  • Development Distribution Score (DDS): 0.266
Past Year
  • Commits: 65
  • Committers: 8
  • Avg Commits per committer: 8.125
  • Development Distribution Score (DDS): 0.108
Top Committers
Name Email Commits
George Stagg g****g@r****m 722
Lionel Henry l****y@g****m 224
Jeroen Ooms j****s@g****m 12
Colin Fay c****n@t****r 4
Josiah Parry j****y@g****m 3
Hatem Hosny h****y 2
James J Balamuta c****s 2
Maciej Nasinski n****j@g****m 2
Barret Schloerke b****t@p****o 1
Christian Lawson-Perfect c****t@g****m 1
Dipterix Wang 8****x 1
Hannes h@n****v 1
Hiroaki Yutani y****i@g****m 1
Jack Zhao b****r@h****m 1
Luis Verde Arregoitia l****d@c****x 1
Thomas Wells t****s@g****m 1
Winston Chang w****n@s****g 1
banky 4****e 1
derrickstaten 6****n 1
drgomulka 8****a 1
Maxim Stogniy m****y@y****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 253
  • Total pull requests: 195
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 13 days
  • Total issue authors: 119
  • Total pull request authors: 23
  • Average comments per issue: 2.44
  • Average comments per pull request: 1.0
  • Merged pull requests: 178
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 55
  • Pull requests: 41
  • Average time to close issues: 26 days
  • Average time to close pull requests: 15 days
  • Issue authors: 41
  • Pull request authors: 8
  • Average comments per issue: 1.4
  • Average comments per pull request: 0.8
  • Merged pull requests: 34
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • georgestagg (21)
  • jeroen (15)
  • JosiahParry (12)
  • coatless (10)
  • bugzpodder (8)
  • hturner (8)
  • Dual-Ice (6)
  • ColinFay (6)
  • christianp (5)
  • isbool (5)
  • psychemedia (4)
  • adrianolszewski (4)
  • WillemSleegers (4)
  • timelyportfolio (4)
  • SugarRayLua (4)
Pull Request Authors
  • georgestagg (164)
  • lionel- (21)
  • jeroen (19)
  • dipterix (5)
  • coatless (4)
  • ColinFay (4)
  • derrickstaten (2)
  • schloerke (2)
  • JosiahParry (2)
  • yutannihilation (2)
  • drgomulka (2)
  • christianp (2)
  • hatemhosny (2)
  • luisDVA (2)
  • Dual-Ice (2)
Top Labels
Issue Labels
bug (34) feature (26) question (15) enhancement (12) accessibility (8) docs (6) documentation (4) package request (4) tidy-dev-day :nerd_face: (3) packages (3) duplicate (1) help wanted (1)
Pull Request Labels

Dependencies

.github/workflows/deploy.yml actions
  • actions/checkout v4 composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • aws-actions/configure-aws-credentials v1 composite
  • codecov/codecov-action v3 composite
  • docker/build-push-action v5 composite
  • docker/login-action v3 composite
  • docker/metadata-action v5 composite
  • quarto-dev/quarto-actions/setup v2 composite
  • r-lib/actions/setup-r v2 composite
.github/workflows/test.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
packages/webr/DESCRIPTION cran
  • utils * imports
Dockerfile docker
  • $BASE latest build
  • webr latest build
tools/dragonegg/Dockerfile docker
  • ubuntu 20.04 build
src/package-lock.json npm
  • 642 dependencies
src/package.json npm
  • @types/emscripten ^1.39.6 development
  • @types/jest ^28.1.8 development
  • @types/node ^17.0.35 development
  • @types/react ^18.2.15 development
  • @types/react-dom ^18.2.7 development
  • @typescript-eslint/eslint-plugin ^5.51.0 development
  • @typescript-eslint/parser ^5.51.0 development
  • c8 ^7.12.0 development
  • esbuild ^0.17.19 development
  • esbuild-css-modules-plugin ^2.2.16 development
  • eslint ^8.33.0 development
  • eslint-config-google ^0.14.0 development
  • eslint-plugin-jest ^26.8.7 development
  • eslint-plugin-jsdoc ^46.2.4 development
  • eslint-plugin-react ^7.32.2 development
  • gts ^3.1.0 development
  • jest ^28.1.3 development
  • ts-jest ^28.0.8 development
  • ts-node ^10.9.1 development
  • typedoc ^0.23.20 development
  • typedoc-plugin-markdown ^3.13.6 development
  • typescript ^4.9.5 development
  • @codemirror/autocomplete ^6.8.1
  • @codemirror/commands ^6.2.4
  • @codemirror/state ^6.2.1
  • @codemirror/view ^6.15.0
  • @msgpack/msgpack ^2.8.0
  • codemirror ^6.0.1
  • codemirror-lang-r ^0.1.0-2
  • lightningcss ^1.21.5
  • react ^18.2.0
  • react-accessible-treeview ^2.6.1
  • react-dom ^18.2.0
  • react-icons ^4.10.1
  • tsx ^3.12.7
  • xmlhttprequest-ssl ^2.1.0
  • xterm ^5.1.0
  • xterm-addon-fit ^0.7.0
  • xterm-readline ^1.1.1