R playground

Write and run R in your browser, with nothing to install: a pocket RStudio with the console, plots, an environment with your variables and the Statistical Methods packages. To try the scripts from the ME1 articles, do the exercises on your phone or revise before the exam (there you will use RStudio, and everything here works the same way).

How to use it

  • Files: they are the tabs at the top: your .R scripts and your data (.csv, .txt). + creates a new one; the pencil (or a double click on its name) renames it, and the cross deletes it. read.csv("data.csv") reads the tab with that name.
  • Run runs the whole script you have open, like «Source» with echo in RStudio: each line appears in the Console with > and its result below. Every run starts with an empty environment. If there is an error, R stops there and a card explains what happened and how to fix it, with «Go to line» and «Ask Leo».
  • The console at the bottom is like RStudio’s: type a command and press Enter. It works with what your script left behind (try mean(marks) after the example), and ↑ and ↓ bring back the previous ones.
  • Plots: they appear inside the console, right after the line that draws them, and in the Plots tab, where you see them large and download them as PNG. lines(), abline() or legend() add to the last one, also from the console at the bottom.
  • Environment: the variables that exist, with their type and a summary (like RStudio’s Environment pane).
  • Step by step walks through the script expression by expression: you see what each one does, how the environment changes and the output so far; with «Explain it slowly», what each function does (pnorm, quantile, sd…).
  • Packages: with library(MASS) (or any other from the course) it installs itself the first time you use it.
  • Your code is saved automatically in this browser. Settings holds the rest: light or dark theme, text size, helps, uploading and downloading files, sharing a link with your code and «Restore my previous code».
  • Challenges: six statistics exercises, from easy to hard, with the data in datos.txt. «Check» tests your script with several datasets and tells you which ones fail; you get hints one at a time and, if you are stuck, the solution.

Keyboard shortcuts

ShortcutWhat it does
Ctrl + EnterRuns the open script
Ctrl + SpaceShows the suggestions (they also appear as you type)
Tab or EnterAccepts the highlighted suggestion
Ctrl + /Comments or uncomments the selected lines (with #)
Ctrl + FFind and replace
Enter and ↑ ↓ in the console at the bottomRuns the command and goes through the previous ones

On a Mac, Cmd instead of Ctrl.

What you can and cannot do

  • It is real R 4.6 (webR: R compiled to WebAssembly), with its usual packages: stats, graphics, utils…
  • The ME1 and ME2 packages work: MASS, fitdistrplus, TeachingDemos, UsingR, extraDistr, car, lmtest, mfx, lsr, dplyr, tidyr, readr and readxl. rootSolve and xlsx are not available: here, solve one-unknown equations with uniroot() and read data with read.csv(); in RStudio, for the exam, you can use them.
  • Data goes in the script or in a file: readline() does not ask you, just as when you run a whole script in RStudio.
  • Each run can last at most 30 seconds: a simulation that is too long stops by itself, and there is also the Stop button.
  • The first time it downloads about 20 MB (the whole of R); after that it starts in a couple of seconds. Each package is downloaded the first time you load it.

Practice with it

  • The Statistical Methods I topics will arrive in University, each with its full script to paste here and try.
  • If you also code in other languages, there is the Python, the Java and the C playground, and all of them together in Playgrounds.