-
Notifications
You must be signed in to change notification settings - Fork 69
/
GuidedTT_Emmys.Rmd
144 lines (130 loc) · 2.98 KB
/
GuidedTT_Emmys.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
title: "Guided Tidy Tuesday: gt edition"
author: "Kyla McConnell"
date: "9/29/2021"
output: html_document
---
```{r}
library(tidyverse)
library(gt)
library(scales)
nominees <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-09-21/nominees.csv')
```
```{r}
colnames(nominees)
```
```{r}
nominees %>%
distinct(category)
```
```{r}
summary(nominees$year)
```
## Which shows have won the most awards?
```{r}
nominees %>%
filter(type == "Winner") %>%
distinct(category, title) %>%
count(title) %>%
arrange(desc(n))
nominees %>%
filter(type == "Winner") %>%
distinct(category, title) %>%
group_by(title) %>%
tally() %>%
arrange(desc(n))
```
## Which distributors have won the most awards this year?
```{r}
winners <- nominees %>%
filter(type == "Winner" & year == 2021) %>%
mutate(distributor = recode(distributor,
"Apple TV+" = "Apple TV",
"App Store, Apple TV+" = "Apple TV",
"HBO Max" = "HBO"
)) %>%
count(distributor) %>%
top_n(10) %>%
arrange(desc(n))
```
```{r}
winners_gt <- winners %>%
gt() %>%
tab_header(
title = md("**2021 Emmy Winners**"),
subtitle = md("**Top 10 distributors by Emmy wins**")
) %>%
tab_source_note("Source: TidyTuesday Github") %>%
cols_label(
distributor = "",
n = ""
) %>%
data_color(
columns = n,
colors = scales::col_numeric(
palette = c("white", "#63BAAB"),
domain = NULL
)
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(distributor)
)
winners_gt %>%
gtsave("emmys_distributor2021.png",
expand = 20)
```
## Costume winners
```{r}
costumes <- nominees %>%
filter(str_detect(category, "Costume") & year == 2021) %>%
mutate(category = str_remove(category, "Outstanding"),
category = str_remove(category, "Costumes - 2021"),
category = str_trim(category)) %>%
filter(category %in% c("Period", "Contemporary", "Fantasy/Sci-Fi"))
```
```{r}
costumes %>%
distinct(category, type, title, distributor) %>%
arrange(desc(type)) %>%
gt(
groupname_col = "category"
) %>%
tab_header(
title = md("**2021 Emmy Awards for Costume**"),
subtitle = md("**in the categories Period, Contemporary, and Fantasy/Sci-Fi**")
) %>%
tab_source_note("Source: TidyTuesday Github") %>%
cols_label(
type = "",
title = md("**Title**"),
distributor = md("**Distributor**")
) %>%
tab_style(
style = cell_fill(color = "lightblue"),
location = cells_body(rows = type == "Winner")
) %>%
tab_style(
style = list(
cell_text(weight = "bold"),
cell_fill(color = "#F1F1F1")
),
location = cells_row_groups()
) %>%
tab_options(
row_group.border.top.color = "black"
) %>%
cols_align(
align = "center",
columns = title
) %>%
cols_align(
align = "right",
columns = distributor
) %>%
cols_width(
type ~ px(100),
distributor ~ px(100),
title ~ px(200)
)
```