R Compiler
Run R code online with R 4.6, data frames, the stats package and datasets like mtcars. webR runs it in your browser, so your code and data stay private.
Something not working, or missing a feature? Send feedback
About the R Compiler
The online R Compiler runs R 4.6 in your browser with webR, so you can test a function, summarise a data frame or fit a quick linear model without installing R or RStudio. The base packages and built-in datasets such as mtcars and iris are included, and your code and data never leave your device.
Your code runs in an isolated Web Worker in your browser, so it never leaves your device.
How to use the R Compiler
- Write or paste an R script.
- Put input your script reads with readline() or readLines("stdin") in the stdin box.
- Click Run. The first run downloads R (about 15 MB); later runs start immediately.
- Read the printed values; warnings and errors appear where they happen, as in Rscript.
Example
Input
model <- lm(mpg ~ wt, data = mtcars) round(coef(model), 3) predict(model, data.frame(wt = 3))
Result
(Intercept) wt
37.285 -5.344
1
21.25171Each top-level value is printed, as in Rscript. Fuel economy drops by about 5.3 miles per gallon per 1,000 lb, and a 3,000 lb car is predicted to do 21.3 mpg.
Common mistakes
- Values print only at the top level. A bare expression prints when it is a line of the script, but not inside a for loop, an if block or a function. Wrap it in print() or use cat() there.
- readline() on your own computer. Here readline() reads a line from the stdin box, but Rscript on your computer returns an empty string because it is not interactive. For scripts that should work in both places, read input with readLines("stdin").
- Indexing starts at 1. x[1] is the first element and x[0] silently returns an empty vector instead of an error, a common source of empty results when porting code from Python or C.
Works well with the R Compiler
- CSV to JSON: turn CSV data into JSON for other tools.
- Python Compiler: compare the analysis with pandas-style code in Python.
- SQL Playground: try the same aggregation as a SQL query.
Frequently asked questions
Which packages are available?
The base R packages: base, stats, utils, methods, graphics, grDevices, datasets, splines, stats4, grid, tools and parallel. CRAN packages such as dplyr or ggplot2 cannot be installed in this sandbox.
Are plots shown?
No. Plot functions run without errors, but the output panel shows text only. Use print(), summary() and table() to inspect results.
Is my code sent to a server?
No. R runs in your browser as WebAssembly (webR), so the code, its input and any data you paste stay on your device.
Can I use it instead of RStudio?
For quick scripts, exercises and checking a function, yes. For plots, CRAN packages and projects with data files, use R or RStudio on your computer.
Related tools
JavaScript Compiler
Run JavaScript online in an isolated browser sandbox. See console output, errors and execution time instantly, with top-level await and stdin input.
TypeScript Compiler
Compile and run TypeScript online. Your code is type-checked with the official compiler in strict mode, then runs in a sandboxed worker in your browser.
Python Compiler
Run Python 3 code online with the full standard library and stdin input. It runs in your browser with Pyodide (WebAssembly), so your code stays on your device.
PHP Compiler
Run PHP 8.4 code online and see the output instantly, with stdin input and mbstring. PHP runs in your browser with WebAssembly, so your code stays private.
C Compiler
Compile and run C code online with Clang 21, a GCC-compatible compiler, and stdin input. Programs run in your browser as WebAssembly, so your code stays private.
C++ Compiler
Compile and run C++20 code online with Clang 21, libc++ and stdin input. Programs compile to WebAssembly and run in your browser, so your code stays private.