Interactive WebR Playground
Run Mills ratio examples directly in your browser
2026-02-02
Source:vignettes/webr-playground.qmd
Welcome to the WebR Playground
This interactive environment lets you run Mills ratio examples directly in your browser - no R installation required!
The millsratio package is compiled to WebAssembly and loaded automatically from our custom WebR repository.
Package Setup
First, we load the millsratio package:
Quick Start Examples
Example 1: Basic Mills Ratio Calculation
Try calculating Mills ratios for different distributions. Click “Run Code” to execute:
Example 2: The t(30) Paradox
Explore why t(30) appears normal but has fatter tails:
Example 3: Tidyverse Analysis
Use dplyr and tidyr for Mills ratio analysis:
Example 4: Hazard Function Analysis
Explore the relationship between Mills ratio and hazard function:
Example 6: Verify Mills Ratio Properties
Test the theoretical properties of Mills ratios:
Your Turn! 🚀
Now try modifying the examples above or write your own code. Here’s a blank cell to get started:
Advanced Example: Monte Carlo Verification
Verify Mills ratio calculations using simulation:
Tips for Using WebR Playground
- Click “Run Code” to execute any code block
- Modify examples directly in the code cells
- Core tidyverse packages are available (dplyr, tidyr) - Note: ggplot2 has known issues with WebR, use base plotting instead
- Mills ratio functions are pre-loaded - no installation needed
- Results appear immediately below each code block
Common Tasks
Compare Any Two Distributions
Explore Different Parameters
Resources
Troubleshooting
If code doesn’t run: 1. Make sure you clicked “Run Code” 2. Check for typos in function names 3. Ensure required libraries are loaded 4. Refresh the page if WebR becomes unresponsive
Happy exploring! 🎯