WebR – R in the Browser
(docs.r-wasm.org)104 points by sieste 4 days ago
104 points by sieste 4 days ago
I really like R. I find it a nice language to work in. I'm glad to see projects like this that make it more accessible.
Here’s a ggplot2 example: https://webr.sh/#code=eJxtkLFOwzAQhsWapzh5ckSUpEgsSBkY2RAVrN...
What does this mean in practice? Does this mean you could start with a blank .html file, and use html, css, and javascript (like normal), but then somehow run R too? e.g. to generate a ggplot using the browser (as opposed to server, as a shiny app may)?
Has anyone got a minimal reproducible examples (e.g. tiny html file that runs, say 2 * 2 in R)? The example linked to in the article has the key line <script type="module" src="repl.mjs"></script>, but that mjs file goes over my head.
Curious/eager/excited to know/see what kinds of real-world applications this has.
There’s a simplified example here: https://github.com/r-wasm/webr/tree/main/src/examples/eval
I don't think so, not yet. There's been Julia-on-wasm efforts that have been inching along for a while, but it's not nearly at a mature point afaik. I remember reading that some new developments (maybe shifting more of the compiler work to Julia with JuliaLowering.jl, maybe something else) have made wasm a lot more feasible, but it's gonna need some people with a need for it to actually work on it.
(From context I'm assuming you're not looking for something like Jupyter/Pluto/BonitoBook.)
Probably uses LLVM Flang to make the Fortran parts happen, compiling reference BLAS and LAPACK. As the main dev for WebR is also the one who did this [0].
Cool but 12MB WASM blob. I wish there was a way of making these WASM builds significantly smaller.
Usually they are shipped in a compressed form. If 12MB is compressed it could be that it represents the entire R runtime to support the general R REPL. It could be possible to reduce the payload by compiling only what's necessary to run a particular R program into the wasm binary. That should cut down size considerably.
If you want to use it to create ggplot2 charts, here is an open source demo: https://github.com/QuesmaOrg/demo-webr-ggplot/
I created it as a side project from using WebR to execute code LLM-generated code (https://quesma.com/blog-detail/sandboxing-ai-generated-code-...). While we migrated away from it, I saw that WebR is cool, and I wanted to share it with you.