Interactive R in Your Browser with WebR
Run R Code in Your Browser - No Installation Required!
Have you ever wanted to try out R code quickly without installing anything? The WebR Playground lets you write and execute R code directly in your browser. It’s perfect for beginners who want to experiment with R or for quick code testing when you’re away from your main development environment.
What is WebR?
WebR is a version of R compiled to WebAssembly, allowing you to run R code directly in your web browser. This means:
- No installation required
- Instant access to R functionality
- Run code on any device with a modern browser
Try Our WebR Playground
We’ve created a simple WebR Playground that you can use right now. Just click the link and start coding!
Please note that this basic implementation has some limitations:
- No plotting capability is available
- Package installation is not supported
- Only basic R functionality is available
For full R functionality, we recommend using RStudio or other complete R environments.
Example Code to Try
Here are some simple R code examples you can try in the WebR Playground:
Basic Calculations
# Basic arithmetic
2 + 2 * 5
sqrt(16)
log(10)
# Create and manipulate vectors
<- c(1, 2, 3, 4, 5)
x mean(x)
sd(x)
sum(x)
Data Analysis
# Create some sample data
<- 1:10
x <- c(2, 4, 6, 8, 7, 12, 14, 16, 18, 20)
y
# Print the data
cat("x values:", x, "\n")
cat("y values:", y, "\n")
# Calculate some statistics
<- mean(x)
mean_x <- mean(y)
mean_y cat("Mean of x:", mean_x, "\n")
cat("Mean of y:", mean_y, "\n")
# Fit a linear model
<- lm(y ~ x)
model summary(model)
Working with Built-in Datasets
# Explore the built-in mtcars dataset
data(mtcars)
head(mtcars)
summary(mtcars)
# Basic statistics
cor(mtcars$mpg, mtcars$wt)
t.test(mtcars$mpg[mtcars$am == 0], mtcars$mpg[mtcars$am == 1])
Future Enhancements
We’re working on enhancing our WebR Playground with more features in the future, including:
- Support for basic plotting
- Access to more packages
- Ability to save and share code snippets
In the meantime, enjoy experimenting with R code in your browser!