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.
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.
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.
Here are some lessons you might find useful, though you may feel free to do whatever lessons you choose. I’ll list the overall package, the specific lesson, and the last lesson I think you’ll need to complete in DataCamp before attempting it.
| package.name | lesson.name | attempt.after |
|---|---|---|
| Getting and Cleaning Data | Manipulating Data with dplyr | Summarise and the pipe operator |
| Getting and Cleaning Data | Grouping and Chaining with dplyr | Summarise and the pipe operator |
| R Programming | Logic | Loops |
| R Programming | Functions | Functions |
| R Programming | lapply and sapply | The apply family |
| R Programming | vapply and tapply | The apply family |
I will attempt to update this list dynamically as the class progresses.