Teaching statistics with R
R lets students see an idea happen: simulate it, plot it, change one number and watch the result move. This page models four ways to use it in a classroom. Each tab pairs a live demo with the R code that would produce it. Teaching tip: ask students to predict the result before they run code. Prediction followed by surprise is where most of the learning happens. Try this: choose Exponential, set n = 1 and draw. Then n = 5, 30, 100. The dark line is the normal curve the theorem predicts; watch the bars hug it. Discuss: the line fits the points you give it, nothing more. Does one extreme point deserve to change the story? Score: 0 / 4What R offers a classroom
Free and reproducible
No licence cost for students. A script records every step, so a result can be rerun and checked by anyone.RStudio and Posit Cloud
A friendly editor with console, plots and file panes. Cloud workspaces avoid install problems on day one.R Markdown and Quarto
Code, output and explanation live in one document. Students submit a report that regenerates its own figures.learnr and swirl
Interactive tutorials with exercises, hints and auto-graded answers, inside the browser or the R console.Shiny apps
Turn a concept into a slider-driven app, like the demos on these tabs, and share it with a link.webR
R running directly in the browser through WebAssembly, so a class can run code with nothing installed.A four-week sample unit
Week 1: Look at data
Load a built-in dataset with mtcars or iris. Use str(), summary() and hist(). Goal: describe a distribution in words.Week 2: Simulate to understand sampling
Use replicate() and rnorm() to build sampling distributions. Goal: explain why sample means vary and how sample size changes that.Week 3: Model relationships
Fit lm(), plot with abline(), read residuals. Goal: interpret slope and R² for a real question.Week 4: Communicate
Wrangle with dplyr, plot with ggplot2, and write a one-page Quarto report. Goal: a reproducible analysis someone else can rerun.Central Limit Theorem simulator
Pick a population shape, then draw many samples and plot each sample's mean. Even when the population is skewed or two-humped, the means pile up into a bell curve as the sample size grows.Fit a line by clicking
Each click adds a student: hours studied on the horizontal axis, exam score on the vertical axis. R's lm() finds the least-squares line. Add an outlier at the far corner and watch the slope react.Wrangle a gradebook
A tiny data frame of 12 students. Change the options and the matching dplyr pipeline and its result update together, so students connect each verb to what it does to the table.See the full data frame
Quick check
Four questions with immediate feedback, the kind of low-stakes practice you can put in a learnr tutorial.