forked from markrt/eurovision_2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemi qualifiers info.R
153 lines (139 loc) · 3.45 KB
/
semi qualifiers info.R
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
## adding a variable from the semi qualifiers etc
# load packages
library(tidyverse)
library(ggbeeswarm)
# load data
spotify_data <-
read_csv("eurovision_spotify_data_2022.csv")
# creat three categories:
# qualifiers
# NQs
# big five
semi_1_qualifiers <-
c("Lithuania",
"Switzerland",
"Ukraine",
"Netherlands",
"Moldova",
"Portugal",
"Iceland",
"Greece",
"Norway",
"Armenia")
semi_1_nq <-
c("Albania",
"Latvia",
"Slovenia",
"Bulgaria",
"Croatia",
"Denmark",
"Austria")
semi_2_qualifiers <-
c("Finland",
"Serbia",
"Azerbaijan",
"Australia",
"Estonia",
"Romania",
"Poland",
"Belgium",
"Sweden",
"Czech Republic")
semi_2_nq <-
c("Israel",
"Georgia",
"Malta",
"San Marino",
"Cyprus",
"Ireland",
"North Macedonia",
"Montenegro")
big_five <-
c("United Kingdom",
"France",
"Italy",
"Germany",
"Spain")
# add flags to data
spotify_data <-
spotify_data %>%
mutate(semi_outcome =
case_when(
country %in% semi_1_qualifiers ~ "Qualified",
country %in% semi_2_qualifiers ~ "Qualified",
country %in% semi_1_nq ~ "NQ",
country %in% semi_2_nq ~ "NQ",
country %in% big_five ~ "Big Five"
)) %>%
mutate(which_semi =
case_when(
country %in% semi_1_qualifiers ~ "Semi 1",
country %in% semi_1_nq ~ "Semi 1",
country %in% semi_2_qualifiers ~ "Semi 2",
country %in% semi_2_nq ~ "Semi 2",
country %in% big_five ~ "Big Five"
))
# some quick exploratory work
# just to check it's working ok
spotify_data %>%
group_by(semi_outcome) %>%
summarise(mean_tempo =
mean(tempo))
# mean tempo among qualifiers is actually 9 bpm faster than nqs
spotify_data %>%
group_by(semi_outcome) %>%
mutate(mean_tempo =
mean(tempo)) %>%
ggplot() +
aes(x = tempo,
y = semi_outcome) +
geom_point(aes(x = mean_tempo),
size = 10,
colour = "skyblue") +
geom_point() +
theme_minimal() +
labs(x = "BPM",
y = "",
title = "On average, qualifiers were a bit quicker",
subtitle = "Big Five looking slow",
caption = "@markrt")
### look i'm a bit sceptical of the "popularity" variable
# but let's see if one semi was tougher than the other
spotify_data %>%
filter(semi_outcome != "Big Five") %>%
group_by(which_semi) %>%
mutate(mean_popularity =
mean(track.popularity)) %>%
ggplot() +
aes(y = fct_rev(which_semi),
x = track.popularity) +
geom_point(aes(x = mean_popularity),
size = 10,
colour = "skyblue") +
geom_point() +
theme_minimal() +
labs(x = "Spotify's mysterious popularity variable",
y = "")
# with the lot
spotify_data %>%
filter(semi_outcome != "Big Five") %>%
group_by(which_semi) %>%
summarise(mean_popularity =
mean(track.popularity))
# 60.5 vs 58.2
# wipe out the one weird outlier
spotify_data %>%
filter(semi_outcome != "Big Five" &
track.popularity > 40) %>%
group_by(which_semi) %>%
summarise(mean_popularity =
mean(track.popularity))
# leaves them fairly similar to one another
# all three of these qualified!!!
spotify_data %>%
filter(tempo > 124 &
tempo < 132)
# and these two!!!
spotify_data %>%
filter(tempo > 82 &
tempo < 89)