-
Notifications
You must be signed in to change notification settings - Fork 4
/
Readme.Rmd
337 lines (282 loc) · 10.4 KB
/
Readme.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
---
title: "Introducing {linkinpark}"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(linkinpark)
library(tidyverse)
library(gt)
library(delabj)
table_style_lp <- function(gt){
gt%>%
opt_align_table_header(align= "left") %>%
tab_options(
column_labels.border.top.color = "white",
column_labels.border.top.width = px(3),
column_labels.border.bottom.color = "#90998A",
table_body.hlines.color = "white",
table.border.bottom.color = "white",
table.border.bottom.width = px(3),
table.border.top.color = "white",
table.margin.left = px(20)
) %>%
tab_style(
style = list(
cell_text(
font = google_font("Montserrat"),
size = px(25),
align = "left"
)
),
locations = list(
cells_title(groups = "title")
)
)
}
```
<img src='linkinpark.png' align="right" height="138" />
With the 20th anniversary of Hybrid Theory by Linkin Park, I decided to put together a data package that contains a few different datasets about the band.
## How To Get
You can install the package using the remotes package
`remotes::install_github('delabj/linkinpark')`
## What's Inside
### Data
#### Albums Charted By Billboard
This is a relatively small data set containing data about peak positions on The Billboard Hard Rock Chart. This data includes the album name, peak position reached, the date it peaked and the number of weeks the album charted.
```{r billboard_albums_example,message=FALSE,warning=FALSE }
billboard_albums %>%
head() %>%
knitr::kable()
```
#### RIAA Awards
This dataset is a collection of awards from the Recording Industry Association of America that were given to Linkin Park. The RIAA certifies an album as gold after 500,000 sales, platinum with 1,000,000 sales, and then diamond after 10,000,000 sales. This data is sourced from the RIAA gold/platinum search. Their database however does not include diamond awards due to their rarity. For certification purposes a sale is a unit equivalent to one of the following:
- Sale of a digital of physical album
- 10 individual track downloads
- 1500 instances of streamed audio of video from the album
```{r, echo = FALSE}
tribble(~Variable, ~Description,
"album_title" , "Name of the album",
"release_date" , "Date of album release",
"format" , "Type of release (album or single)",
"certification" , "Certification level (gold, platinum)",
"certification_date", "Date of certification",
"plat_modifer" , "Number of times the album has reached platinum"
) %>%
knitr::kable()
```
#### /r/linkinpark Top 100 Songs
This data comes from a poll on [/r/linkinpark](<http://www.reddit.com/r/linkinpark)> using [allourideas](http://www.allourideas.org/linkinparksongs) where users selected their favorite song in head to head pairings. There were over 47,000 votes and this was the official results as of 2020-07-02.
```{r, echo = FALSE}
tribble(~Variable, ~Description,
"Rank" , "Ranking of the song",
"Track" , "Name of the track",
"Album" , "Album the track appeared on",
"score" , "The Percentage of wins of a given song"
) %>%
knitr::kable()
```
#### Audio Features
A data set created by using the {`spotifyr`} package to access the spotify API's audio features for all Linkin Park Content on spotify. This is provided as a connivance instead of a user set up a spotify API workflow.
## Examples
Using the billboard data for charted albums we can easily make a table with [{gt}](https://gt.rstudio.com/)
```{r, billboard_data, echo=TRUE, message=FALSE, eval = FALSE}
billboard_albums %>%
arrange(date_peaked) %>%
gt::gt() %>%
cols_label(album_title = "Album",
peak_position = "Peak Position",
date_peaked = "Date Peaked",
weeks_on_chart = "Weeks Charted") %>%
tab_header(md("**Linkin Park On Billboard's Hard Rock Chart**"))%>%
data_color(
columns = vars(weeks_on_chart),
colors = scales::col_numeric(
c("white", "#F39524"),
domain = NULL
)
) %>%
fmt_date(columns = vars(date_peaked), date_style = 7) %>%
cols_align(align = "right", columns = vars(date_peaked)) %>%
opt_table_lines(extent = "default") %>%
tab_options(
column_labels.border.top.color = "white",
column_labels.border.top.width = px(3),
column_labels.border.bottom.color = "#90998A",
table_body.hlines.color = "white",
table.border.bottom.color = "white",
table.border.bottom.width = px(3),
table.border.top.color = "white",
table.margin.left = px(20)
) %>%
opt_align_table_header(align= "left") %>%
tab_style(
style = list(
cell_text(
font = google_font("Montserrat"),
size = px(25),
align = "left"
)
),
locations = list(
cells_title(groups = "title")
)
) %>%
tab_source_note("Data: Billboard.com" )
```
![gt\_example\_table](Readme_files/img/gt_example.png)
Using the spotify audio features we can see how different aspects of the bands sound evolved over time
```{r, message = FALSE, warning = FALSE}
audio_features %>%
filter(album_name %in%
genius_lycics$album) %>% distinct() %>%
select(
track_name,
album_name,
album_release_date,
danceability,
energy,
speechiness,
acousticness,
valence
) %>%
mutate(album_release_date = lubridate::ymd(album_release_date),
age = lubridate::ymd("2020-10-01") - album_release_date,
age = as.numeric(age, units = "days")/365)%>%
pivot_longer(
names_to = "measure",
values_to = "values",
cols = c(danceability,
energy,
speechiness,
acousticness,
valence)
) %>%
group_by(
track_name,
album_name,
age,
measure
)%>%
# There are duplicate listings based on region
# and they can vary on values slightly
summarise(values = median(values)) %>%
ungroup() %>%
mutate(measure = factor(measure, levels = c("valence", "acousticness", "speechiness", "danceability",
"energy"
))) %>%
filter(str_detect(tolower(album_name), "live", TRUE)) %>%
ggplot(aes(x=measure, y = values))+
geom_line(aes(color = age, group = track_name), alpha = .3, size= .02)+
geom_point(aes(color = age))+
theme_delabj()+
scale_color_delabj("zune", discrete = FALSE)+
guides(
color = guide_colorbar(title = "Track Age",
title.position = "top",
title.hjust = .5,
barwidth = 15
))+
labs(
title = "Linkin Park's Audio Features",
y=NULL)
```
Or we can look at these by just the albums for a slightly less chaotic plot
```{r, warning=FALSE, message=FALSE}
release_dates <- audio_features %>%
filter(album_type=="album") %>%
group_by(album_name, ) %>%
summarize(album_release_date = max(album_release_date)) %>%
filter(str_detect(tolower(album_name), "live", TRUE)) %>%
filter(str_detect(tolower(album_name), "acapellas", TRUE)) %>%
filter(album_name %in%
genius_lycics$album) %>% distinct() %>%
arrange(album_release_date)
audio_features %>%
filter(album_type=="album") %>%
group_by(track_name, album_name) %>%
summarize(energy=median(energy)) %>%
filter(str_detect(tolower(album_name), "live", TRUE)) %>%
filter(str_detect(tolower(album_name), "acapellas", TRUE)) %>%
filter(album_name %in%
genius_lycics$album) %>%
mutate(album_name = factor(album_name, levels = release_dates$album_name)) %>%
ggplot(aes(x=album_name, y = energy))+
geom_boxplot(aes(color = album_name,
fill = album_name),
alpha = .3)+
geom_point(aes(color =album_name), position = "jitter")+
theme_delabj()+
scale_color_delabj("retro")+
scale_fill_delabj("retro")+
labs(
title = "The Energy of Linkin Park Albums",
y=NULL,
x=NULL,
color = "Album Name",
fill = "Album Name")+
legend_none()+
scale_x_discrete(guide = guide_axis(n.dodge = 2))
```
We can also look at the RIAA certifications
```{r, warning=FALSE, message=FALSE}
riaa_lp %>%
na.omit() %>%
dplyr::filter(format == "Album") %>%
mutate(size = case_when(
certification == "Gold" ~ 500000,
TRUE ~ 1000000
)) %>%
ggplot()+
geom_point(aes(x=certification_date,
y = fct_reorder(album_title, release_date),
size = size, color = album_title),
alpha = .75)+
geom_vline(aes(xintercept = lubridate::ymd("2017-07-20"), alpha = .5))+
theme_delabj()+
scale_color_delabj()+
scale_size_continuous(range = c(4, 8))+
labs(
title = "Linkin Park Timeline of Awards",
subtitle = "After Chester Died there was a resurgance of purchaces",
y = NULL,
x = "Date")+
legend_none()+
geom_text(data = data.frame(x = as.Date("2015-04-06"),
y = 8.32247240968638,
label = "Chester's Death"),
mapping = aes(x = x,
y = y,
label = label),
angle = 0L,
lineheight = 1L,
hjust = 0.5,
vjust = 0.5,
colour = "black",
family = "sans",
fontface = "plain",
inherit.aes = FALSE,
show.legend = FALSE)+
geom_curve(data = data.frame(x = as.Date("2014-10-21"),
y = 7.83474315204446,
xend = as.Date("2017-06-08"),
yend = 4.55069948392219),
mapping = aes(x = x,
y = y,
xend = xend,
yend = yend),
angle = 90L,
colour = "black",
curvature = 0.5,
arrow = structure(list(angle = 30,
length = structure(0.1,
class = "unit",
valid.unit = 2L,
unit = "inches"),
ends = 2L,
type = 2L),
class = "arrow"),
inherit.aes = FALSE,
show.legend = FALSE)+
theme(axis.text.y = element_text(hjust = 0))
```