1.2 Following along
Hands–on practice is the only way to gain competence in using R for data analysis. With that in mind, we present R code and output throughout the guide. These serve as (hopefully) useful examples for reference and, most importantly, as an opportunity to practice on your own. When you see a code chunk and output, we want you to follow along by entering the code on your computer and comparing your output to what's given in the guide. Consider a chunk like the one below:
# Summarize miles per gallon (mpg)
summary(mtcars$mpg)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 10.4 15.4 19.2 20.1 22.8 33.9
Throughout the text, you’ll find that annotation and comments follow a single #
and appear in light blue:
# Summarize miles per gallon (mpg)
The actual R commands, below, come in a mix of black, dark blue, and other accent colors. Where possible, they are shown within a pink box. Type and execute these commands in R as you follow along with the guide.
summary(mtcars$mpg)
The output from the commands—what you will see in the console window after executing—follows ##
.
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 10.4 15.4 19.2 20.1 22.8 33.9
Be sure to check your output against what you find here. If your output is different, or if you get an error message, review your code for typos and errors.