Installation and use
Install all the packages in the tidyverse by running
library(tidyverse)to load the core tidyverse and make available in your current R session.
Learn more about the tidyverse package at http://tidyverse.tidyverse.org.
The core tidyverse includes the packages that you're likely to use in every day data analyses. As of tidyverse 1.1.0, the following packages are included in the core tidyverse:
purrr enhances R’s functional programming (FP) toolkit by providing a complete and consistent set of tools for working with functions and vectors. Once you master the basic concepts, purrr allows you to replace many for loops with code that is easier to write and more expressive. Learn more ...
tibble is a modern re-imaginging of the data frame, keeping what time has proven to be effective, and throwing out what it has not. Tibbles are data.frames that are lazy and surly: they do less and complain more forcing you to confront problems earlier, typically leading to cleaner, more expressive code. Learn more ...
The tidyverse also includes many other packages with more specialised usage. They are not loaded automatically with
library(tidyverse), so you’ll need to load each one with its own call to
As well as readr, for reading flat files, the tidyverse includes:
There are a handful of other packages that are not in the tidyverse, but are tidyverse-adjacent. They are very useful for importing data from other sources:
jsonlite for JSON.
xml2 for XML.
httr for web APIs.
rvest for web scraping.
- stringr for strings.
- lubridate for dates and date-times.
- forcats for categorical variables (factors).
- hms for time-of-day values.
- blob for storing blob (binary) data.
As well as purrr which faciliates functional programming, there are two tidyverse packages that help with general programming challenges:
rlang provides tools to work with core language features of R and the tidyverse
magrittr provides the pipe,
%>%used throughout the tidyverse. It also provide a number of more specialised piping operators (like
%<>%) that can be useful in other places.
glue provides an alternative to
paste()that makes it easier to combine data and strings.
Modelling within the tidyverse is largely a work in progress. You can see some of the pieces in the recipes and rsample packages but we do not yet have a cohesive system that solves a wide range of challenges. This work will largely replace the modelr package used in R4DS.
You may also find broom to be useful: it turns models into tidy data which you can then wrangle and visualise using the tools you already know.