Playground
WebR Playground
Interactive R environment running directly in your browser
WebR Playground
This page demonstrates the interactive R capabilities provided by the vitepress-webr package. WebR allows you to run R code directly in the browser without any server-side setup.
- Click "Run" to execute R code
- All code blocks share the same R environment on this page
- WebR downloads on first use (~20MB)
Basic Examples
Start with simple R expressions:
R
Hello World
R
Vector operations
R
Working with data frames
Data Visualization
Create beautiful plots with R's graphics system:
R
Basic scatter plot
R
Box plot
R
Histogram with normal curve
R
Line plot with multiple series
Statistical Analysis
Perform statistical tests and modeling:
R
Linear regression
R
Correlation analysis
R
T-test
Advanced: ggplot2 (if available)
Note: ggplot2 may need to be loaded. Try this example:
R
ggplot2 example
Variable Persistence
Variables are shared across code blocks on this page:
R
Define variables
R
Reuse variables from previous block
Markdown Syntax
You can use the webr language identifier in code blocks to create interactive cells:
```webr
print("Hello")
```
```webr title="With Title"
print("Hello")
```
- First run: Downloads WebR runtime (~20MB); subsequent runs are instant
- Variable persistence: Variables persist within this page; navigating away resets the environment
- Package availability: Core R packages are available; some additional packages may need to be loaded
- Performance: Most R operations run with good performance via WebAssembly
- Not all R packages are available in WebR
- Some packages requiring system dependencies may not work
- Large datasets may consume significant browser memory