1.2 Following along

Hands on practice is the only way to gain competence in using R for data analysis. To We present code and output throughout the guide so that you have useful examples for reference and, most importantly, for you to practice. 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.40   15.43   19.20   20.09   22.80   33.90

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)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.40   15.43   19.20   20.09   22.80   33.90

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.40   15.43   19.20   20.09   22.80   33.90

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.