What Is swirl?
swirl is an interactive teaching system that runs directly inside the R console. It introduces concepts in small steps, asks questions, evaluates the commands you enter, and provides immediate feedback.
Active Practice Matters
Watching someone else program can make code look understandable without making it usable. swirl requires you to enter commands yourself, which helps convert passive recognition into practical skill.
Step 1: Install the swirl Package
Open RStudio and enter the following command in the Console. You only need to install the package once on a given R installation.
install.packages("swirl")
Selecting a CRAN Mirror
If R asks you to select a CRAN mirror, choose a location geographically close to you or select the cloud mirror. The mirror is simply a server from which R downloads the package.
Step 2: Load swirl
Packages must be loaded each time you begin a new R session and want to use them.
library(swirl)
Step 3: Install the R Programming Course
After loading swirl, install its introductory R Programming curriculum by running:
install_course("R Programming")
Package Installation and Course Installation Are Separate
install.packages("swirl") installs the software. install_course("R Programming") downloads the instructional lessons. Both steps are required.
Step 4: Start swirl
Start the interactive tutorial by entering:
swirl()
Follow the prompts to choose a name, select the R Programming course, and begin a lesson. Your swirl name does not need to be your legal name.
Leaving and Returning to swirl
Enter bye() when you want to leave swirl. To return later, open RStudio, load the package with library(swirl), and run swirl() again.