ggplot 102: Facets, Scales, Labels, and Themes (but now 🐶) recitation

Week 6

Author

Jessica Cooperstone

Three dogs looking longingly at the camera as they are about to have dinner. On the left is Nacho, Jess's cream colored French Bulldog, in the middle is Petunia, a black American Staffordshire Terrier, and on the right is Inu, a white and grey Pitbull.

Nacho (Jess’s dog, left) along with his friends Petunia (middle) and Inu (right) waiting for dinner

Introduction

We will practice what we learned this week in ggplot102 on:

Load libraries and data

Before we get started, let’s load our libraries and data. Today we will be looking again at some different data from the Tidy Tuesday project (here is the Github repo) about dog breeds.

install.packages("tidytuesdayR")
library(tidyverse)
library(tidytuesdayR)

We will be using the data that is from February 1, 2022, so let’s download it. The readme for this data is here.

tuesdata <- ???

Let’s look at it. How can you do that?

Investigating

Write code to determine what the 5 most popular dog breeds in 2020 were. There are many ways to do this.

Create a new variable that is a sum of all the ranks from 2013, allowing a composite score of the popularity of each dog breed across this time period.

What are the 5 most popular and the 5 least popular dogs across this time frame? There are many ways to do this.

Visualization 1

Create a plot where you take the 12 most popular dogs from 2020, and plot their popularity rank from 2013 to 2020.

To facet, you need to have the variable you want to facet in one column.

Visualization 2

Alter the aesthetics of this plot until you think it looks good.

Investigate more

What dog has jumped in the rankings most from 2013 to 2020? What has dropped the most?

Back to top