data <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-03-11/public_response.csv")
## Rows: 24 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): film, cinema_score
## dbl (3): rotten_tomatoes, metacritic, critics_choice
##
## ℹ 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.
data_small <- data %>%
select(rotten_tomatoes,metacritic,cinema_score) %>%
filter(rotten_tomatoes %in% c("100","96"))
data_small %>% pivot_wider(names_from =rotten_tomatoes,values_from = metacritic)
## # A tibble: 3 × 3
## cinema_score `100` `96`
## <chr> <dbl> <dbl>
## 1 A 95 96
## 2 A+ 88 79
## 3 <NA> NA 83
data_small %>% slice(-5)
## # A tibble: 4 × 3
## rotten_tomatoes metacritic cinema_score
## <dbl> <dbl> <chr>
## 1 100 95 A
## 2 100 88 A+
## 3 96 79 A+
## 4 96 96 A
data_small_unique <- data_small %>% slice(-5)
data_small_unique %>%
pivot_wider(names_from = rotten_tomatoes, values_from = metacritic)
## # A tibble: 2 × 3
## cinema_score `100` `96`
## <chr> <dbl> <dbl>
## 1 A 95 96
## 2 A+ 88 79
data_long <- data_small_unique %>% pivot_wider(names_from = rotten_tomatoes, values_from = metacritic)
data_wide <- data_small_unique %>% pivot_wider(names_from = rotten_tomatoes, values_from = metacritic)
data_wide %>% pivot_longer(`100`:`96`,names_to = "rotten_tomatoes", values_to = "metacritic")
## # A tibble: 4 × 3
## cinema_score rotten_tomatoes metacritic
## <chr> <chr> <dbl>
## 1 A 100 95
## 2 A 96 96
## 3 A+ 100 88
## 4 A+ 96 79
skimr::skim(data)
| Name | data |
| Number of rows | 24 |
| Number of columns | 5 |
| _______________________ | |
| Column type frequency: | |
| character | 2 |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: character
| skim_variable | n_missing | complete_rate | min | max | empty | n_unique | whitespace |
|---|---|---|---|---|---|---|---|
| film | 0 | 1.00 | 2 | 19 | 0 | 24 | 0 |
| cinema_score | 2 | 0.92 | 1 | 2 | 0 | 3 | 0 |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 | hist |
|---|---|---|---|---|---|---|---|---|---|---|
| rotten_tomatoes | 1 | 0.96 | 89.17 | 14.15 | 40 | 84 | 96 | 97.5 | 100 | ▁▁▂▂▇ |
| metacritic | 1 | 0.96 | 79.96 | 12.32 | 57 | 71 | 81 | 90.0 | 96 | ▃▃▆▆▇ |
| critics_choice | 3 | 0.88 | 87.14 | 9.40 | 66 | 81 | 89 | 93.0 | 100 | ▂▂▂▇▅ |
data_united <- data %>%
unite(col = "newName", rotten_tomatoes:metacritic, sep = "/", remove = TRUE)
data_united %>%
separate(col = newName, into = c("rotten_tomatoes","metacritic"), sep= "/")
## # A tibble: 24 × 5
## film rotten_tomatoes metacritic cinema_score critics_choice
## <chr> <chr> <chr> <chr> <dbl>
## 1 Toy Story 100 95 A NA
## 2 A Bug's Life 92 77 A NA
## 3 Toy Story 2 100 88 A+ 100
## 4 Monsters, Inc. 96 79 A+ 92
## 5 Finding Nemo 99 90 A+ 97
## 6 The Incredibles 97 90 A+ 88
## 7 Cars 74 73 A 89
## 8 Ratatouille 96 96 A 91
## 9 WALL-E 95 95 A 90
## 10 Up 98 88 A+ 95
## # ℹ 14 more rows
pixar <- tibble(
film = c("Toy Story","A Bug's Life", "Toy Story 2", "Monsters Inc"),
rotten_tomatoes= c(100,92,100,96),
metacritic= c(95,77,88,79),
cirtics_choice= c(NA,NA,100,92)
)