Skip to main content
HomeCheat sheetsR Programming

Tidyverse Cheat Sheet For Beginners

This tidyverse cheat sheet will guide you through the basics of the tidyverse, and 2 of its core packages: dplyr and ggplot2!
Aug 2021  · 7 min read

The tidyverse is a powerful collection of R packages that you can use for data science. They are designed to help you to transform and visualize data. All packages within this collection share an underlying philosophy and common APIs.

As you might know, DataCamp recently launched the Introduction to the Tidyverse course together with David Robinson, Data Scientist at Stack Overflow.

Now, DataCamp has created a tidyverse cheat sheet for beginners that have already taken the course and that still want a handy one-page reference or for those who need an extra push to get started on discovering this popular collection of packages. You must have already run into packages such as ggplot2 and dplyr, so this cheat sheet will definitely come in handy!

It's a quick guide through the basics of manipulating and visualizing your data the powerful tools that the tidyverse has to offer in R!

Have this cheat sheet at your fingertips

Download PDF

The tidyverse cheat sheet will guide you through some general information on the tidyverse, and then covers topics such as useful functions, loading in your data, manipulating it with dplyr and lastly, visualize it with ggplot2.

In short, everything that you need to kickstart your data science learning with R!

Do you want to learn more? Also check out and star the Exploratory Data Analysis in R: Case Study course, also taught by David Robinson, for free now!

Also, don't miss out on our data.table cheat sheet for data manipulation in R and our other cheat sheets for data science.

What is Tidyverse?  

The tidyverse is a powerful collection  of  R  packages  that are actually  data tools for transforming and visualizing data. All packages of the tidyverse share an underlying philosophy and common APls.

The core packages are: 

  • ggplot2, which implements the grammar of graphics. You can use it to visualize your data.
  • dplyr is a grammar of data You can use it to solve the most common data manipulation challenges.
  • tidyr helps you to create tidy data or data where each variable is in a column, each observation is a row end each value is a column, each observation is a row end each value is a cell. 
  • readr is a fast and friendly way to read rectangular
  • purrr enhances R"s functional programming (FP)toolkit by providing a complete and consistent set of tools for working with functions and vectors. 
  • tibble is a modern re-imaginging of the data
  • stringr provides a cohesive set of functions designed to make working with strings as easy as possible
  • forcats provide a suite of useful  tools that solve common problems with factors.  

You can install the complete tidyverse with:

> install.packages("tidyverse")

Then, load the core tidyverse and make it available in your current R session by running:

> library(tidyverse)

Note: there are many other tidyverse 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 library().

Useful Functions

> tidyverse_conflicts() #Conflicts between tidyverse and other packages
> tidyverse_deps() #List all tidyverse dependencies
> tidyverse_logo() #Get tidyverse logo, using ASCII or unicode characters
> tidyverse_packages() #List all tidyverse packages
> tidyverse_update() #Update tidyverse packages

Loading in the Data 

>	library(datasets) #Load the datasets package
>	library(gapminder) #Load the gapminder package
>	attach(iris) #Attach iris data to the R search path



filter() allows you to select a subset of rows in a data frame.

>iris%>% #Select iris data of species "virginica"

>iris%>% #Select iris data of species "virginica" and sepal length greater than 6. 
           Sepal.Length> 6)


arrange() sorts the observations in a dataset in ascending or descending order based on one of its variables.

>iris%>% #Sort in ascending order of sepal length
>iris%>% #Sort in descending order of sepal length

Combine multiple dplyr verbs in a row with the pipe operator %>%:

>iris%>% #Filter for species "virginica" then arrange in descending order of sepal length
          filter(Species="virginica") %>% 


mutate() allows you to update or create new columns of a data frame.

>iris%>% #Change Sepal.Length to be in millimeters
>iris%>% #Create a new column called SLMm

Combine the verbs filter(), arrange(), and mutate():

     filter(Species="Virginica") %>% 
     mutate(SLMm=Sepal.Length*10) %>% 


summarize() allows you to turn many observations into a single data point.

>iris%>% #Summarize to find the median sepal length 

>iris%>% #Filter for virginica then summarize the median sepal Length
     filter(Species="virginica") %>% 

You can also summarize multiple variables at once:

     filter(Species="virginica") %>% 

group_by () allows you to summarize within groups instead of summarizing the entire dataset:

>iris%>% #Find median and max sepal length of each species 
     group_by(Species) %>% 

>iris%>% #Find median and max petal length of each species with sepal length> 6 
     filter(Sepal.Length>6) %>%
     group_by(Species) %>% 


Scatter Plot 

Scatter plots allow you to compare two variables within your data. To do this with ggplot2, you use geom_point()

>iris_small f- iris%>%
     filter(Sepal.Length > 5)

>ggplot(iris_small, aes(x=Petal.Length, #Compare petal width and length
     y=Petal.Width)) + geom_point()

Additional Aesthetics


>ggplot(iris_small, aes(x=Petal.Length, 
     calar=Species)) + 


>ggplot(iris_small, aes(x=Petal.Length,
          size=Sepal.Length)) +


>ggplot(iris_small, aes(x=Petal.Length,
          y=Petal.Width)) +

 Line Plots 

>	by_year <-- gapminder %>% 
          group_by(year) %>%
>	ggplot(by_year, aes(x=year,

Bar Plots 

> by_species <--iris%>% 
     filter(Sepal.Length>6) %>% 
     group_by(Species) %>% 
> ggplot(by_species, aes(x=Species,
          y=medianPL)) +


> ggplot(iris_small, aes(x=Petal.Length))+ 

Box Plots 

> ggplot(iris_small, aes(x=Species,

(Click above to download a printable version or read the online version below).

Learn more about Tidyverse

Here are a few extra Tidyverse resources to get you started:

Introduction to the Tidyverse

Working with Data in the Tidyverse

Network Analysis in the Tidyverse

Machine Learning in the Tidyverse


5 Common Data Science Challenges and Effective Solutions

Emerging technologies are changing the data science world, bringing new data science challenges to businesses. Here are 5 data science challenges and solutions.
DataCamp Team's photo

DataCamp Team

8 min

Navigating R Certifications in 2024: A Comprehensive Guide

Explore DataCamp's R programming certifications with our guide. Learn about Data Scientist and Data Analyst paths, preparation tips, and career advancement.
Matt Crabtree's photo

Matt Crabtree

8 min

A Data Science Roadmap for 2024

Do you want to start or grow in the field of data science? This data science roadmap helps you understand and get started in the data science landscape.
Mark Graus's photo

Mark Graus

10 min

Data Storytelling and Visualization with Lea Pica from Present Beyond Measure

Richie and Lea cover the full picture of data presentation, how to understand your audience, leverage hollywood storytelling and much more.
Richie Cotton's photo

Richie Cotton

71 min

Introduction to DynamoDB: Mastering NoSQL Database with Node.js | A Beginner's Tutorial

Learn to master DynamoDB with Node.js in this beginner's guide. Explore table creation, CRUD operations, and scalability in AWS's NoSQL database.
Gary Alway's photo

Gary Alway

11 min

How to Transpose a Matrix in R: A Quick Tutorial

Learn three methods to transpose a matrix in R in this quick tutorial
Adel Nehme's photo

Adel Nehme

See MoreSee More