Tidyverse
R is an old programming language that was written as a re-implementation of the even older language, S. Over the years this has meant that R has gained many different layers and methods of doing things. This has created lots of inconsistencies and cruft, with R sometimes behaving in strange and unexpected ways that can be confusing for new users, and not suited to applications in modern data science.
The tidyverse is a coherent collection of modern R packages that solves this problem. It is a coherent system of packages for data manipulation, exploration and visualization that share a common design philosophy. The packages were originally mostly developed by Hadley Wickham, but have been expanded by several contributers and has now developed into a thriving and highly supportive community.
There is lots of information about tidyverse on the web, e.g. R for Data Science (2e) is an online book by Hadley Wickham, Mine Çetinkaya-Rundel and Garrett Grolemund, that teaches the concepts of tidy data and shows how R with the tidyverse will help you create tidy data workflows. Modern R is the tidyverse, and it is strongly recommend that you use the tidyverse when you use R for data science.
Installing and loading the tidyverse
You can install and use tidyverse by typing:
install.packages("tidyverse")
library(tidyverse)This will download and then import tidyverse modules. Remember you only need to run install.packages("tidyverse") once. You should see something similar to this printed:
── Attaching core `tidyverse` packages ────────────────────────────────────────────────────────────────── `tidyverse` 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ──────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
This shows that the nine core tidyverse modules have been loaded:
dplyrhttps://dplyr.tidyverse.orgforcatshttps://forcats.tidyverse.orgggplot2https://ggplot2.tidyverse.org/lubridatehttps://lubridate.tidyverse.org/purrrhttps://purrr.tidyverse.orgreadrhttps://readr.tidyverse.orgstringrhttps://stringr.tidyverse.orgtibblehttps://tibble.tidyverse.orgtidyrhttps://tidyr.tidyverse.org
It also shows that the modern dplyr::filter and dplyr::lag functions replace the older stats::filter and stats::lag functions.