The swirl R package makes it fun and easy to learn R programming and data science. If you are new to R, have no fear. On this page, we’ll walk you through each of the steps required to begin using swirl today!
Step 1: Get R
In order to run swirl, you must have R 3.1.0 or later installed on your computer. If you are on a Linux operating system, please visit our Installing swirl on Linux page.
If you need to install R, you can do so here.
For help installing R, check out one of the following videos (courtesy of Roger Peng at Johns Hopkins Biostatistics):
Installing R on Windows Installing R on Mac
Step 2 (recommended): Get RStudio
In addition to R, it’s highly recommended that you install RStudio, which will make your experience with R much more enjoyable.
If you need to install RStudio, you can do so here. Select the appropriate installer for your operating system.
Step 3: Install swirl
Open RStudio (or just plain R if you don't have RStudio) and type the following into the console:
Note that the > symbol at the beginning of the line is R's prompt for you type something into the console. We include it here so you know that this command is to be typed into the console and not elsewhere. The part you type begins after >.
Step 4: Start swirl
This is the only step that you will repeat every time you want to run swirl. First, you will load the package using the library() function. Then you will call the function that starts the magic! Type the following, pressing Enter after each line:
Step 5: Install an interactive course
The first time you start swirl, you'll be prompted to install a course. You can either install one of the recommended courses or visit our course repository for more options. There are even more courses available from the Swirl Course Network.
If you'd like to install a course that is not part of our course repository, type ?InstallCourses at the R prompt for a list of functions that will help you do so.
Step 6: Have fun! Please visit our Help page if you have trouble completing any of these steps.