One of the most appealing aspects of dplyr is the ability to easily manipulate data frames. Each of the dplyr functions you will explore takes a data frame as its first argument.
The pipe operator, or %>%
, helps increase the readability of data frame code by piping the value on its left into the first argument of the function that follows it. For example:
df %>% head()
pipes the data frame df
into the first argument of head()
, becoming
head(df)
The true power of pipes comes from the ability to link multiple function calls together. Once you learn some of dplyr’s functions, we’ll revisit pipes and see how they are so useful!
Note: the pipe operator is not a part of base R. It comes from the magrittr
package, but do not worry about loading magrittr in your code. Any time you load a package from the tidyverse, like dplyr, %>%
will automatically be loaded!
Instructions
Use a pipe %>%
to inspect artists
with head()
.