1.18 R tidyverse

In this book, we will start by learning how to carry out data management tasks using base R, but there will also be examples that use the tidyverse. You really need to know base R, but also knowing how to use the tidyverse can make many tasks much easier.

All of the code in previous sections used only base R. The functions in the tidyverse package (Wickham et al. 2019; Wickham 2023b) will be used a lot in Chapters 3 and 4 for managing variables and datasets.

For now, we will just introduce an object type that is unique to the tidyverse. A tibble is a type of data.frame used specifically in the tidyverse set of packages. A tibble has multiple classes: tbl_df and data.frame, so it can be handled like a data.frame but also in has some special features unique to the class tbl_df.

If you have not already done so, then install the tidyverse package.

# You only have to run this code once
install.packages("tidyverse")

When you need to use functions in the tidyverse, load the library.

library(tidyverse)

References

———. 2023b. Tidyverse: Easily Install and Load the Tidyverse. https://tidyverse.tidyverse.org.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.