Part 19 Selecting and sorting data frames
19.1 Learning Objectives
Here are the concepts we’ll be exploring in this lesson:
- tidyverse
- dplyr functions:
select()
arrange()
- piping
By the end of this lesson, students are expected to be able to:
- subset and rearrange data with dplyr
- use piping (
|>
) when implementing function chains
19.2 Preamble
Let’s talk about:
- The history of dplyr: plyr
- Don’t use both in one script!
- My recommendation, don’t use plyr at all at this point.
- tibbles are a special type of data frame
- The tidyverse
- Package functions and masking
- Load the tidyverse package:
library(tidyverse)
- Load the tidyverse package:
19.3 Demonstration
Let’s get started with an exercise:
- Download this Rmd worksheet.
- Save it to your class GitHub repo with a name like
exercise-dplyr.Rmd
. - Open the worksheet in RStudio.
- Follow along in the
.Rmd
file until the Back to Guide section.