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

Idle
R

Vector operations

Idle
R

Working with data frames

Idle

Data Visualization

Create beautiful plots with R's graphics system:

R

Basic scatter plot

Idle
R

Box plot

Idle
R

Histogram with normal curve

Idle
R

Line plot with multiple series

Idle

Statistical Analysis

Perform statistical tests and modeling:

R

Linear regression

Idle
R

Correlation analysis

Idle
R

T-test

Idle

Advanced: ggplot2 (if available)

Note: ggplot2 may need to be loaded. Try this example:

R

ggplot2 example

Idle

Variable Persistence

Variables are shared across code blocks on this page:

R

Define variables

Idle
R

Reuse variables from previous block

Idle

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
Copyright © 2026