Getting Started

R has a useful package for interactive lessons called swirl. There are numerous lessons available for you to get more practice, some of which I will list at the end of this document as recommended exercises. First, I’ll briefly demonstrate how to get up and running with swirl.

Installing and Loading swirl

The swirl package is available through CRAN and can be installed using standard installation tools. The most straightforward way:

install.packages("swirl")

You can then load the package, which will provide some useful intro text telling you how to start the program:

library(swirl)
## 
## | Hi! Type swirl() when you are ready to begin.

Now that swirl is running, let’s talk about how to add content.

Installing Lessons

There are 2 basic ways to install lessons. The first is to start swirl and let it guide you.

swirl()

Note that I’m not showing output here because swirl is interactive and I can’t really do that here. But if you run the command, you’ll be able to quickly get to some basic packages you can have installed. However, the list is pretty short, so if you want more package options, you’ll need another method.

My preferred avenue is to use install_from_swirl() to get new packages. For instance, the “Getting and Cleaning Data” package contains material on dplyr. I can install it as follows:

install_from_swirl("Getting and Cleaning Data")

Once again, I’m not printing out anything because the output isn’t useful. Now that your package is installed, run the swirl() command to start the interactive session and follow the prompts to access your lessons.