Analysis Stage Lab

Real R, running in your browser, with no account or install. It works like RStudio: the script is on the left, and what R prints appears on the right.

How this page works

Run the script in order, from the top. R only knows what you have already run. Load the libraries and the data before Step 0, and run each step before the next. If you see could not find function, object not found, NULL where you expected data, or ...applied to an object of class "function", a line above has not been run yet (often the libraries or the data).

Run line ▸
Runs the line your cursor is on, then moves to the next one. Shortcut Ctrl+Enter (Windows) or Cmd+Enter (Mac). A command that spans several lines runs as a whole. Highlight several lines to run just those.
Run this step
Runs the whole step your cursor is in, from its # STEP heading to the next one.
Restart R
Only active while code is running. Stops a run that is taking too long and starts R fresh. Your script stays, but you need to run it again from the top.
Reset script
Puts the script back to how it started. Your edits and answers are lost, so download first.
Clear console
Empties the console. Nothing in R changes.
Download script
Saves the script with your answers as lab.R. Do this at the end.
Download console
Saves everything R printed, as a text file.
Console line
Type R code under the console and press Enter for a quick check. ↑ brings back earlier commands. It is not saved in your script.
Plots and Data
Plots appear in the bottom-right pane, newest first. The Data tab shows any data frame you have made. Pick it from the dropdown.
Resizing
Drag the gaps between panes. Double-click a gap to reset it.

Your script is saved in this browser as you type, but only on this computer. Want R on your own computer? Install R first, then RStudio Desktop (both free), or use Posit Cloud in a browser. Click the heading above to hide this guide.

Give feedback (anonymous) Starting R… the first time takes about a minute while packages download

Script lab.R

Console


      
>
Plots appear here.
View