induwara.lk
induwara.lkDeveloper · Runs in your browser

Online R Compiler — run R code in your browser

Write R and run it instantly, free, with no signup. It uses real R 4.x · WebAssembly (WebR), so vectors, summary(), data frames and base-R plots all execute in your own browser — your code is never uploaded.

By Induwara AshinsanaUpdated Jun 26, 2026
R code editorR 4.x · WebAssembly (WebR)
Loading editor…
Ready
Console
Press Run to execute your R code. Printed values, warnings and errors appear here.
Plots

Base-R graphics — plot(), hist(), boxplot() — render here as images.

Runs entirely in your browser — your code is never uploaded.

How it works

This compiler runs WebR — the official build of R (the same R 4.x engine you would install from r-project.org) compiled to WebAssembly by the r-wasm project. When you press Run, your code executes inside a sandboxed Web Worker in your browser, not on our server. That makes it private (nothing is uploaded), effortless to scale (your device does the work), and unable to reach our systems or other users.

Because it is the real interpreter, results are identical to desktop R to the last digit. Functions such as mean(), sd(), summary() and lm() follow the definitions in the R language reference. For example, the quartiles in summary()use R's default type-7 sample-quantile rule (Hyndman & Fan, 1996): for a sorted vector of length n and probability p, it interpolates at position h = (n − 1)·p. The worked examples below were reconciled to that rule by hand and reproduced in TypeScript to confirm the engine's output.

Execution is captured through WebR's output API: standard output and standard error stream back to the page in the order R emits them, and top-level expressions auto-print exactly as they would in the R console (so a bare mean(x) prints [1] 6). Base-R graphics are routed to WebR's offscreen canvas device; each plotting call produces an image that is transferred to the Plot pane.

A few deliberate limits keep things safe and fast. The runtime and base R image (about 30 MB) are fetched only on your first Run, so the page itself stays light; after that they are cached. Runs reuse one persistent R global environment, so variables carry over between runs until you press Reset session. Each Run is wrapped in a 25-second timeout and an output cap — if code runs too long, the worker is terminated automatically and your tab stays usable, a guarantee you only get by running in a worker rather than on the main thread. Only packages published as WebAssembly binaries can be installed; native-compiled CRAN packages, local file access and network calls from R are out of scope in this version.

Worked examples

Vector and summary statistics

R input

x <- c(2, 4, 6, 8, 10)
mean(x)
summary(x)

Console output

[1] 6
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
      2       4       6       6       8      10

Cross-checked in TypeScript with R's type-7 quantile rule — identical to base R's summary(): Min 2, 1st Qu. 4, Median 6, Mean 6, 3rd Qu. 8, Max 10. Mean = (2+4+6+8+10)/5 = 30/5 = 6.

A base-R histogram

R input

v <- c(5, 7, 7, 8, 9, 9, 9, 10, 12, 14)
hist(v, main = "Distribution of v", col = "steelblue")

Console output

(no printed value — hist() returns invisibly; the chart appears in the Plot pane)

The Plot pane renders the histogram with the given title and fill colour. Here n = 10 and the mean is 90/10 = 9; the value 9 occurs three times, so the tallest bar sits over the bin containing 9.

Errors and unavailable packages (edge case)

R input

summary(lm(dist ~ speed, data = cars))   # works: a built-in dataset
library(tidyverse)                       # not a WebAssembly binary

Console output

Call:
lm(formula = dist ~ speed, data = cars)
...
Error in library(tidyverse) : there is no package called 'tidyverse'

The model on the built-in cars dataset runs normally, then the missing-package error is shown in red in the Console pane — not swallowed. Built-in datasets and base/recommended packages are available; packages without a WebAssembly build are not.

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, an edge case, or want another language added?

Email me at [email protected] — most fixes ship within 24 hours.