/
.Rapp.history
292 lines (292 loc) · 14.6 KB
/
.Rapp.history
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
# server.R#
library(devtools)#
library(Rspotify)#
library(dplyr)#
library(knitr)#
#
shinyServer(function(input, output) {#
## Authorizes Spotify API with keys#
keys <- spotifyOAuth("Info 201","ae706b417cc645f78c559186204dadd4","5f5769652ae24ceca43e05074b8b84eb")#
source("functions/GetSongData.R")#
source("functions/Combine.features.by.year.R")#
output$rolePlot <- renderPlot({#
## Read in songs for each year#
songs.2015 <- read.csv("Songs/Songs - 2015.csv")#
songs.2014 <- read.csv("Songs/Songs - 2014.csv")#
songs.2013 <- read.csv("Songs/Songs - 2013.csv")#
songs.2012 <- read.csv("Songs/Songs - 2012.csv")#
songs.2011 <- read.csv("Songs/Songs - 2011.csv")#
songs.2010 <- read.csv("Songs/Songs - 2010.csv")#
songs.2009 <- read.csv("Songs/Songs - 2009.csv")#
songs.2008 <- read.csv("Songs/Songs - 2008.csv")#
#
## Grabbing audio features for the years and putting them into respective data frames#
features.2016 <- read.csv("features/features.2016.csv")#
features.2015 <- read.csv("features/features.2015.csv")#
features.2014 <- read.csv("features/features.2014.csv")#
features.2013 <- read.csv("features/features.2013.csv")#
features.2012 <- read.csv("features/features.2012.csv")#
features.2011 <- read.csv("features/features.2011.csv")#
features.2010 <- read.csv("features/features.2010.csv")#
features.2009 <- read.csv("features/features.2009.csv")#
features.2008 <- read.csv("features/features.2008.csv")#
## all the features combines#
all.features <- list(#
'features.2008' = features.2008,#
'features.2009' = features.2009,#
'features.2010' = features.2010,#
'features.2011' = features.2011,#
'features.2012' = features.2012,#
'features.2013' = features.2013,#
'features.2014' = features.2014,#
'features.2015' = features.2015,#
'features.2016' = features.2016#
)#
## Merge them into one for use in some graphs#
features.all.songs <- read.csv("songsMerged/songs.merged.all.csv")#
#
## Calculate danceability averages#
features.2016.danceability <- mean(features.2016$danceability)#
features.2015.danceability <- mean(features.2015$danceability)#
features.2014.danceability <- mean(features.2014$danceability)#
features.2013.danceability <- mean(features.2013$danceability)#
features.2012.danceability <- mean(features.2012$danceability)#
features.2011.danceability <- mean(features.2011$danceability)#
features.2010.danceability <- mean(features.2010$danceability)#
features.2009.danceability <- mean(features.2009$danceability)#
features.2008.danceability <- mean(features.2008$danceability)#
## Calculate energy averages#
features.2016.energy <- mean(features.2016$energy)#
features.2015.energy <- mean(features.2015$energy)#
features.2014.energy <- mean(features.2014$energy)#
features.2013.energy <- mean(features.2013$energy)#
features.2012.energy <- mean(features.2012$energy)#
features.2011.energy <- mean(features.2011$energy)#
features.2010.energy <- mean(features.2010$energy)#
features.2009.energy <- mean(features.2009$energy)#
features.2008.energy <- mean(features.2008$energy)#
## Calculate tempo averages#
features.2016.tempo <- mean(features.2016$tempo)#
features.2015.tempo <- mean(features.2015$tempo)#
features.2014.tempo <- mean(features.2014$tempo)#
features.2013.tempo <- mean(features.2013$tempo)#
features.2012.tempo <- mean(features.2012$tempo)#
features.2011.tempo <- mean(features.2011$tempo)#
features.2010.tempo <- mean(features.2010$tempo)#
features.2009.tempo <- mean(features.2009$tempo)#
features.2008.tempo <- mean(features.2008$tempo)#
## Calculate loudness averages#
features.2016.loudness <- mean(features.2016$loudness)#
features.2015.loudness <- mean(features.2015$loudness)#
features.2014.loudness <- mean(features.2014$loudness)#
features.2013.loudness <- mean(features.2013$loudness)#
features.2012.loudness <- mean(features.2012$loudness)#
features.2011.loudness <- mean(features.2011$loudness)#
features.2010.loudness <- mean(features.2010$loudness)#
features.2009.loudness <- mean(features.2009$loudness)#
features.2008.loudness <- mean(features.2008$loudness)#
## Calculate speechiness averages#
features.2016.speechiness <- mean(features.2016$speechiness)#
features.2015.speechiness <- mean(features.2015$speechiness)#
features.2014.speechiness <- mean(features.2014$speechiness)#
features.2013.speechiness <- mean(features.2013$speechiness)#
features.2012.speechiness <- mean(features.2012$speechiness)#
features.2011.speechiness <- mean(features.2011$speechiness)#
features.2010.speechiness <- mean(features.2010$speechiness)#
features.2009.speechiness <- mean(features.2009$speechiness)#
features.2008.speechiness <- mean(features.2008$speechiness)#
## Calculate acousticness averages#
features.2016.acousticness <- mean(features.2016$acousticness)#
features.2015.acousticness <- mean(features.2015$acousticness)#
features.2014.acousticness <- mean(features.2014$acousticness)#
features.2013.acousticness <- mean(features.2013$acousticness)#
features.2012.acousticness <- mean(features.2012$acousticness)#
features.2011.acousticness <- mean(features.2011$acousticness)#
features.2010.acousticness <- mean(features.2010$acousticness)#
features.2009.acousticness <- mean(features.2009$acousticness)#
features.2008.acousticness <- mean(features.2008$acousticness)#
## Calculate acousticness averages#
features.2016.liveness <- mean(features.2016$liveness)#
features.2015.liveness <- mean(features.2015$liveness)#
features.2014.liveness <- mean(features.2014$liveness)#
features.2013.liveness <- mean(features.2013$liveness)#
features.2012.liveness <- mean(features.2012$liveness)#
features.2011.liveness <- mean(features.2011$liveness)#
features.2010.liveness <- mean(features.2010$liveness)#
features.2009.liveness <- mean(features.2009$liveness)#
features.2008.liveness <- mean(features.2008$liveness)#
## Calculate instrumentalness averages#
features.2016.instrumentalness <- mean(features.2016$instrumentalness)#
features.2015.instrumentalness <- mean(features.2015$instrumentalness)#
features.2014.instrumentalness <- mean(features.2014$instrumentalness)#
features.2013.instrumentalness <- mean(features.2013$instrumentalness)#
features.2012.instrumentalness <- mean(features.2012$instrumentalness)#
features.2011.instrumentalness <- mean(features.2011$instrumentalness)#
features.2010.instrumentalness <- mean(features.2010$instrumentalness)#
features.2009.instrumentalness <- mean(features.2009$instrumentalness)#
features.2008.instrumentalness <- mean(features.2008$instrumentalness)#
#
# Select audio features to show#
if(input$features == "Danceability") {#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.danceability,#
features.2015.danceability,#
features.2014.danceability,#
features.2013.danceability,#
features.2012.danceability,#
features.2011.danceability,#
features.2010.danceability,#
features.2009.danceability,#
features.2008.danceability),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'danceability'))#
)#
} else if(input$features == "Energy"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.energy,#
features.2015.energy,#
features.2014.energy,#
features.2013.energy,#
features.2012.energy,#
features.2011.energy,#
features.2010.energy,#
features.2009.energy,#
features.2008.energy),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'energy'))#
)#
} else if(input$features == "Tempo"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.tempo,#
features.2015.tempo,#
features.2014.tempo,#
features.2013.tempo,#
features.2012.tempo,#
features.2011.tempo,#
features.2010.tempo,#
features.2009.tempo,#
features.2008.tempo),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'tempo'))#
)#
#
} else if(input$features == "Loudness"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.loudness,#
features.2015.loudness,#
features.2014.loudness,#
features.2013.loudness,#
features.2012.loudness,#
features.2011.loudness,#
features.2010.loudness,#
features.2009.loudness,#
features.2008.loudness),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'loudness'))#
)#
#
} else if(input$features == "Speechiness"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.speechiness,#
features.2015.speechiness,#
features.2014.speechiness,#
features.2013.speechiness,#
features.2012.speechiness,#
features.2011.speechiness,#
features.2010.speechiness,#
features.2009.speechiness,#
features.2008.speechiness),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'speechiness'))#
)#
#
} else if(input$features == "Acousticness"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.acousticness,#
features.2015.acousticness,#
features.2014.acousticness,#
features.2013.acousticness,#
features.2012.acousticness,#
features.2011.acousticness,#
features.2010.acousticness,#
features.2009.acousticness,#
features.2008.acousticness),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'acousticness'))#
)#
#
} else if(input$features == "Liveness"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.liveness,#
features.2015.liveness,#
features.2014.liveness,#
features.2013.liveness,#
features.2012.liveness,#
features.2011.liveness,#
features.2010.liveness,#
features.2009.liveness,#
features.2008.liveness),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'liveness'))#
)#
#
} else if(input$features == "Instrumentalness"){#
dat <- data.frame(#
year = factor(c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008), levels=c(2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008)),#
stat_average = c(features.2016.instrumentalness,#
features.2015.instrumentalness,#
features.2014.instrumentalness,#
features.2013.instrumentalness,#
features.2012.instrumentalness,#
features.2011.instrumentalness,#
features.2010.instrumentalness,#
features.2009.instrumentalness,#
features.2008.instrumentalness),#
all.years.feature <-Reduce(function(...) merge(..., by='X', all=T), lapply(names(all.features), Merge.feature.year, 'instrumentalness'))#
)#
}#
if(input$plot_types == "Barplot") {#
ggplot(data=dat, aes(x=year, y=stat_average, color=year)) +#
geom_bar(stat="identity")#
} else if(input$plot_types == "Boxplot") {#
ggplot(data = all.years.feature, aes(x=ind, y = value)) + #
geom_boxplot() #
} else if(input$plot_types == "Quantile") {#
##requires a list of all songs with year and features#
}#
})#
output$tablePlot <- renderDataTable({#
merged.2016 <- read.csv("songsMerged/songs.merged.2016.csv")#
merged.2015 <- read.csv("songsMerged/songs.merged.2015.csv")#
merged.2014 <- read.csv("songsMerged/songs.merged.2014.csv")#
merged.2013 <- read.csv("songsMerged/songs.merged.2013.csv")#
merged.2012 <- read.csv("songsMerged/songs.merged.2012.csv")#
merged.2011 <- read.csv("songsMerged/songs.merged.2011.csv")#
merged.2010 <- read.csv("songsMerged/songs.merged.2010.csv")#
merged.2009 <- read.csv("songsMerged/songs.merged.2009.csv")#
merged.2008 <- read.csv("songsMerged/songs.merged.2008.csv")#
# Select years to show#
if(input$year == "2016") {#
merged.2016#
} else if(input$year == "2015") {#
merged.2015#
} else if(input$year == "2014") {#
merged.2014#
} else if(input$year == "2013") {#
merged.2013#
} else if(input$year == "2012") {#
merged.2012#
} else if(input$year == "2011") {#
merged.2011#
} else if(input$year == "2010") {#
merged.2010#
} else if(input$year == "2009") {#
merged.2009#
} else if(input$year == "2008") {#
merged.2008#
}#
})#
output$values <- renderPrint({#
input$radio#
})#
})