Online R - IDE, Editor, Compiler, Interpreter

Run R scripts online with webR, the official WebAssembly build of R: statistics, data frames, linear models and base graphics plots, all in your browser.

R 4.6 (webR 0.6) · Runs in your browser, so your code never reaches our servers.
main.RR
Output

            
        
Ctrl/⌘ + Enter to run

Features of the online R compiler (IDE, editor & interpreter)

Write, run and test R code online for free. This page works as an online R IDE, code editor, compiler and interpreter in one: type your code, press Run and see the output straight away. Everything runs in your browser, with nothing to install and no account to create.

  • Run code instantly: R 4.6 (webR 0.6), with output in under a second after the first load.
  • Code editor: syntax highlighting, line numbers, bracket matching and auto-closing brackets.
  • Clear errors: error messages and warnings appear in the output panel, as they would on your own computer.
  • Full screen: Ctrl/⌘ + Shift + F, adjustable font size, side-by-side or stacked layout and resizable panes.
  • Autosave: your code is kept in your browser; download it as main.R or copy it in one click.
  • Safe to experiment: a time limit and a Stop button end infinite loops.
  • Private: the R runtime runs on your device, so your code is never uploaded.
  • Dark mode and keyboard shortcuts: Ctrl/⌘ + Enter runs the code.
  • Free: no sign-up, no usage limits.

Learn other programming languages

How to use the online R compiler

  1. Write or paste an R script into the editor. Reset example restores the starter script, which summarises a vector, fits a linear model and draws a plot.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac). The whole script runs from top to bottom.
  3. Read the results in the Output panel. Text appears just as it would in the R console, and any plots you draw are shown below it as images.
  4. Choose a time limit of 5, 15 or 60 seconds. A script that runs longer is stopped, and Stop interrupts it at any time.

The first run downloads R itself, about 25 MB, so allow a few seconds. Later visits load it from your browser cache. Save your work with Copy or the main.R download, adjust the font with A− and A+, switch between side-by-side and stacked panes with the layout button, or press Full screen (Ctrl/⌘ + Shift + F, Esc to exit) when you need space for a long script and its plots.

R runs entirely in your browser. Your script and data are not sent to any server, and the editor stores your last script only in your browser's local storage.

What's supported

The page runs R 4.6.0 through webR 0.6, the official WebAssembly build of R. It is the real R interpreter, so functions, vectors, factors, lists and data frames behave as they do in RStudio or the R console.

  • Console-style output: a value on its own line is auto-printed, exactly as when you type it at the > prompt. print(), cat() and message() also work.
  • Errors and warnings from stop(), warning() and R itself are shown in the output.
  • Base graphics: plot(), hist(), barplot(), boxplot(), lines(), abline(), legend() and friends. Each plot appears in the output panel as a 720×450 image.
  • Base R and the recommended packages that ship with webR, including the stats functions (lm(), t.test(), cor(), quantile()) and the built-in datasets such as mtcars and iris.

Limitations:

  • install.packages() is not supported on this page, so packages from CRAN, such as ggplot2 or dplyr, are not available. Stick to base R.
  • No interactive input. readline() and scan() from the keyboard cannot be used, so define your data in the script.
  • No access to files on your computer. Use read.csv(text = "...") to load a small CSV pasted into the script.

A short R walkthrough

# Vectors are the basic unit, and operations work element by element
x <- c(4, 8, 15, 16, 23, 42)
x * 2
mean(x); median(x)
x[x > 10]                      # logical indexing

# Data frames hold tables
df <- data.frame(
  hours = c(1, 2, 3, 4, 5, 6),
  score = c(52, 58, 65, 70, 74, 83)
)
str(df)

# Fit a linear model and inspect it
fit <- lm(score ~ hours, data = df)
summary(fit)
predict(fit, newdata = data.frame(hours = 7))

# Plot the data and the fitted line
plot(df$hours, df$score, pch = 19, xlab = "Hours studied", ylab = "Score")
abline(fit, col = "red", lwd = 2)

summary(fit) prints the coefficients, their standard errors and p-values, and the R-squared. The abline(fit) call draws the regression line on top of the scatter plot, and the image appears right after the text output.

Tips and common pitfalls

  • R indexes from 1, and x[0] silently returns an empty vector rather than an error.
  • Inside a loop or a function, values are not auto-printed. Wrap them in print().
  • Use <- for assignment and == for comparison. = also assigns at the top level, but mixing the two styles makes scripts harder to read.
  • Missing values propagate: mean(c(1, NA, 3)) is NA. Pass na.rm = TRUE to ignore them.
  • Functions that use random numbers, like rnorm() and sample(), give different results each run. Call set.seed(42) first for repeatable output.
Tip: To draw several plots side by side in one image, call par(mfrow = c(1, 2)) before the plotting commands.

Frequently asked questions

Which version of R is this?

R 4.6.0, running on webR 0.6. Run R.version.string to confirm.

Can I use ggplot2, dplyr or the tidyverse?

No. Installing packages is not supported on this page. Base R covers data frames, aggregation (aggregate(), tapply()), modelling and plotting, which is enough for most exercises.

Where do my plots appear?

In the output panel, after the text output, as 720×450 images. Each new high-level call such as plot() or hist() starts a new image.

Can I run other data languages here?

Try the online Python compiler for NumPy and pandas, or the online SQL compiler for queries. All the options are listed under online compilers.

Copied to clipboard