Import your data

data <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2026/2026-06-09/game_films.csv')
## Rows: 439 Columns: 20
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (14): category, subcategory, title, director, release_date_raw, air_dat...
## dbl   (5): worldwide_box_office, rotten_tomatoes, metacritic, budget_low, bu...
## date  (1): release_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Chapter 15

Create a factor

data %>% count(rotten_tomatoes)
## # A tibble: 48 × 2
##    rotten_tomatoes     n
##              <dbl> <int>
##  1               0     1
##  2               1     1
##  3               3     2
##  4               4     3
##  5               8     2
##  6               9     1
##  7              10     2
##  8              11     1
##  9              12     1
## 10              13     1
## # ℹ 38 more rows
rotten_tommatoes_levels <- c("80", "89", "70")

data_rev <- data %>%
    mutate(rotten_tomatoes = rotten_tomatoes %>% factor(levels = rotten_tommatoes_levels))

Modify factor order

Make two bar charts here - one before ordering another after

Modify factor levels

Show examples of three functions:

  • fct_recode

  • fct_collapse

  • fct_lump

Chapter 16

No need to do anything here.