/
Repeatr_1.R
1385 lines (1005 loc) · 52 KB
/
Repeatr_1.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
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#' @name Repeatr_1
#' @title imports raw data in CSV format (1 row per show), cleans the data, and reshapes it long so that the rows are identified by combinations of gid and song_number.
#' @description This was originally developed with a file called "fugotcha.csv", the first line of which went like this:
#' @description washington-dc-usa-90387 FLS0001 03/09/1987 Wilson Center $5 300 Joey Picuri Fugazi Cassette Joe #1 Intro Song #1 Furniture Merchandise Turn Off Your Guns In Defense Of Humans Waiting Room The Word
#' @description "gid" is short for "gig id"
#' @description Another data file that was used was called "releases_songs_durations_wikipedia.csv" and was obtained from the Wikipedia data on the Fugazi discography.
#' @description This file contains the following variables: index releaseid release track_number songid song instrumental vocals_picciotto vocals_mackaye vocals_lally duration_seconds
#'
#' @import dplyr
#' @import stringr
#' @import lubridate
#' @import fastDummies
#' @import rlang
#' @import knitr
#'
#' @param mycsvfile Optional name of CSV file containing Fugazi Live Series data to be used. If omitted, the default file provided with the package will be used.
#' @param mysongdatafile Optional name of CSV file containing song data to be used. If omitted, the default file provided with the package will be used.
#' @param releasesdatafile Optional name of CSV file containing releases data to be used. If omitted, the default file provided with the package will be used.
#'
#' @return
#' @export
#'
#' @examples
#' fugotcha <- system.file("extdata", "fugotcha.csv", package = "Repeatr")
#' releases_songs_durations_wikipedia <- system.file("extdata", "releases_songs_durations_wikipedia.csv", package = "Repeatr")
#' releasesdatafile <- system.file("extdata", "releases.csv", package = "Repeatr")
#' Repeatr_1_results <- Repeatr_1(mycsvfile = fugotcha, mysongdatafile = releases_songs_durations_wikipedia, releasesdatafile = releasesdatafile)
#'
Repeatr_1 <- function(mycsvfile = NULL, mysongdatafile = NULL, releasesdatafile = NULL) {
# Devel setup -------------------------------------------------------------
# Uncomment and run the following lines to test the code outside the package
# library(dplyr)
# library(stringr)
# library(lubridate)
# library(mlogit)
# library(fastDummies)
# library(rlang)
# library(knitr)
# library(crayon)
# library(readr)
# Import data -------------------------------------------------------------
mydir <- getwd()
myinputdir <- paste0(mydir, "/inst/extdata/")
mydatadir <- paste0(mydir, "/data")
if (is.null(mycsvfile)==FALSE) {
Repeatr0 <- read.csv(mycsvfile, header=FALSE)
} else {
fugotcha <- system.file("extdata", "fugotcha.csv", package = "Repeatr")
Repeatr0 <- read.csv(fugotcha, header=FALSE)
rawdata <- Repeatr0 %>%
mutate(date = as.Date(V3, "%Y-%m-%d")) %>%
mutate(year = lubridate::year(date)) %>%
relocate(year)
rawdata$date <- NULL
}
if (is.null(mysongdatafile)==FALSE) {
songvarslookup <- read.csv(mysongdatafile)
} else {
mysongdatafile <- system.file("extdata", "releases_songs_durations_wikipedia.csv", package = "Repeatr")
songvarslookup <- read.csv(mysongdatafile)
}
if (is.null(releasesdatafile)==FALSE) {
releasesdatalookup <- read.csv(releasesdatafile)
} else {
releasesdatafile <- system.file("extdata", "releases.csv", package = "Repeatr")
releasesdatalookup <- read.csv(releasesdatafile)
releasesdatalookup$X <- NULL
}
# Define othervariables data file which includes venue coordinates --------
geocodedatafilename <- system.file("extdata", "fugazi-small.csv", package = "Repeatr")
geocodedatafile <- read.csv(geocodedatafilename)
geocodedatafile$X <- NULL
geocodedatafile <- geocodedatafile %>%
mutate(date = as.Date(date))
othervariables_patchfilename <- system.file("extdata", "othervariables_patch.csv", package = "Repeatr")
othervariables_patchfile <- read.csv(othervariables_patchfilename) %>%
mutate(date = as.Date(date, "%m-%d-%Y"),
checked = 1)
othervariables <- Repeatr0 %>%
select(V1, V2, V3, V4, V5, V6, V7, V8, V9)
othervariables <- othervariables %>%
rename(gid = V1) %>%
rename(flsid = V2) %>%
rename(date = V3) %>%
rename(venue = V4) %>%
rename(doorprice = V5) %>%
rename(attendance = V6) %>%
rename(recorded_by = V7) %>%
rename(mastered_by = V8) %>%
rename(original_source = V9)
othervariables <- othervariables %>%
mutate(date = as.Date(date, "%d/%m/%Y"),
checked = 0)
othervariables <- othervariables %>%
mutate(attendance = as.numeric(attendance))
othervariables <- othervariables %>% left_join(geocodedatafile)
othervariables <- othervariables %>%
mutate(country = ifelse(flsid=="FLS0970", "USA", country),
country = ifelse(city=="Ljubljana" & year>=1991, "Slovenia", country),
country = ifelse(city=="Prague" & year<=1992, "Czechoslovakia", country),
city = ifelse(flsid=="FLS0970", "San Francisco", city),
x = ifelse(flsid=="FLS0970", -122.4272376, x),
y = ifelse(flsid=="FLS0970", 37.760407, y),
tour = ifelse(flsid=="FLS0970", "2000 Summer/Fall Regional Dates", tour),
tour = ifelse(tour=="1993 Fall USA/Canda Tour", "1993 Fall USA/Canada Tour", tour),
year = ifelse(flsid=="FLS0970", 2000, year),
recorded_by = ifelse(flsid=="FLS0970", "Stephen Kozlowski", recorded_by),
checked = ifelse(flsid=="FLS0970", 1, checked))
othervariables <- othervariables %>%
filter(is.na(x)==FALSE)
othervariables <- rbind.data.frame(othervariables, othervariables_patchfile)
# Disambiguation
othervariables <- othervariables %>%
mutate(city = ifelse(country=="England" & city=="Newcastle", "Newcastle-Upon-Tyne", city),
city = ifelse(country=="USA" & city=="Oxford", "Oxford (USA)", city),
city = ifelse(country=="Australia" & city=="Croydon", "Croydon (Australia)", city))
othervariables <- othervariables %>%
mutate(venue = ifelse(country=="USA" & city=="Washington" & venue=="9:30 Club" & year<=1995, "9:30 Club (1980-1995)", venue),
x = ifelse(country=="USA" & city=="Washington" & venue=="9:30 Club (1980-1995)" & year<=1995, -77.0255867, x),
y = ifelse(country=="USA" & city=="Washington" & venue=="9:30 Club (1980-1995)" & year<=1995, 38.8971517, y))
# correct values where necessary
othervariables <- othervariables %>%
mutate(x = ifelse(city=="Newcastle-Upon-Tyne" & venue=="Riverside", -1.6051, x),
y = ifelse(city=="Newcastle-Upon-Tyne" & venue=="Riverside", 54.9717, y),
checked = ifelse(city=="Newcastle-Upon-Tyne" & venue=="Riverside", 1, checked),
x = ifelse(city=="Lisbon" & venue=="Gartejo", -9.1755975, x),
y = ifelse(city=="Lisbon" & venue=="Gartejo", 38.7042177, y),
checked = ifelse(city=="Lisbon" & venue=="Gartejo", 1, checked),
x = ifelse(country == "Japan" & city=="Osaka" & venue=="AM Hall", 135.4995612, x),
y = ifelse(country == "Japan" & city=="Osaka" & venue=="AM Hall", 34.7012144, y),
checked = ifelse(country == "Japan" & city=="Osaka" & venue=="AM Hall", 1, checked),
x = ifelse(country == "Japan" & city=="Osaka" & venue=="Sun Hall", 135.4808578, x),
y = ifelse(country == "Japan" & city=="Osaka" & venue=="Sun Hall", 34.6709861, y),
checked = ifelse(country == "Japan" & city=="Osaka" & venue=="Sun Hall", 1, checked),
x = ifelse(country == "Japan" & city=="Nagoya" & venue=="Club Quattro", 136.9082324, x),
y = ifelse(country == "Japan" & city=="Nagoya" & venue=="Club Quattro", 35.1637276, y),
checked = ifelse(country == "Japan" & city=="Nagoya" & venue=="Club Quattro", 1, checked),
x = ifelse(country == "Japan" & city=="Nagoya" & venue=="Heartland", 136.9192034, x),
y = ifelse(country == "Japan" & city=="Nagoya" & venue=="Heartland", 35.1693198, y),
checked = ifelse(country == "Japan" & city=="Nagoya" & venue=="Heartland", 1, checked),
x = ifelse(country == "USA" & city=="San Francisco" & venue=="Women's Building", -122.4228365, x),
y = ifelse(country == "USA" & city=="San Francisco" & venue=="Women's Building", 37.7614483, y),
checked = ifelse(country == "USA" & city=="San Francisco" & venue=="Women's Building", 1, checked),
x = ifelse(country == "USA" & city=="San Francisco" & venue=="Russian Theater", -122.4413234, x),
y = ifelse(country == "USA" & city=="San Francisco" & venue=="Russian Theater", 37.7854355, y),
checked = ifelse(country == "USA" & city=="San Francisco" & venue=="Russian Theater", 1, checked),
x = ifelse(country == "USA" & city=="San Francisco" & venue=="Fort Mason Pier C", -122.4314681, x),
y = ifelse(country == "USA" & city=="San Francisco" & venue=="Fort Mason Pier C", 37.8067481, y),
checked = ifelse(country == "USA" & city=="San Francisco" & venue=="Fort Mason Pier C", 1, checked),
x = ifelse(country == "USA" & city=="San Francisco" & venue=="Trocadero Transfer", -122.3982015, x),
y = ifelse(country == "USA" & city=="San Francisco" & venue=="Trocadero Transfer", 37.7790623, y),
checked = ifelse(country == "USA" & city=="San Francisco" & venue=="Trocadero Transfer", 1, checked),
x = ifelse(country == "USA" & city=="San Francisco" & venue=="Maritime", -122.3936571, x),
y = ifelse(country == "USA" & city=="San Francisco" & venue=="Maritime", 37.7864189, y),
checked = ifelse(country == "USA" & city=="San Francisco" & venue=="Maritime", 1, checked),
x = ifelse(country == "Germany" & city=="Bremen" & venue=="Schlachthof", 8.8099035, x),
y = ifelse(country == "Germany" & city=="Bremen" & venue=="Schlachthof", 53.0884866, y),
checked = ifelse(country == "Germany" & city=="Bremen" & venue=="Schlachthof", 1, checked),
x = ifelse(country == "Canada" & city=="Ottawa" & venue=="Carleton University Porter Hall", -75.6978497, x),
y = ifelse(country == "Canada" & city=="Ottawa" & venue=="Carleton University Porter Hall", 45.3840001, y),
checked = ifelse(country == "Canada" & city=="Ottawa" & venue=="Carleton University Porter Hall", 1, checked),
x = ifelse(country == "Australia" & city=="Sydney" & (venue=="Metro Theatre" | venue=="Metro"), 151.2066274, x),
y = ifelse(country == "Australia" & city=="Sydney" & (venue=="Metro Theatre" | venue=="Metro"), -33.8756943, y),
checked = ifelse(country == "Australia" & city=="Sydney" & (venue=="Metro Theatre" | venue=="Metro"), 1, checked),
x = ifelse(country == "USA" & city=="Watsonville" & venue=="Veteran's Memorial Hall", -121.7545246, x),
y = ifelse(country == "USA" & city=="Watsonville" & venue=="Veteran's Memorial Hall", 36.9126013, y),
checked = ifelse(country == "USA" & city=="Watsonville" & venue=="Veteran's Memorial Hall", 1, checked),
x = ifelse(country == "Australia" & city=="Wollongong" & venue=="Youth Centre", 150.8928958, x),
y = ifelse(country == "Australia" & city=="Wollongong" & venue=="Youth Centre", -34.4264333, y),
checked = ifelse(country == "Australia" & city=="Wollongong" & venue=="Youth Centre", 1, checked),
x = ifelse(country == "USA" & city=="Fayetteville" & venue=="Studio 225", -94.1667044, x),
y = ifelse(country == "USA" & city=="Fayetteville" & venue=="Studio 225", 36.0657152, y),
checked = ifelse(country == "USA" & city=="Fayetteville" & venue=="Studio 225", 1, checked),
x = ifelse(country == "USA" & city=="Columbia (SC)" & venue=="Dance Graphics", -81.0175133, x),
y = ifelse(country == "USA" & city=="Columbia (SC)" & venue=="Dance Graphics", 34.0032201, y),
checked = ifelse(country == "USA" & city=="Columbia (SC)" & venue=="Dance Graphics", 1, checked),
x = ifelse(country == "Brazil" & city=="Sao Paulo" & venue=="Aeroanta", -46.6949865, x),
y = ifelse(country == "Brazil" & city=="Sao Paulo" & venue=="Aeroanta", -23.5651133, y),
checked = ifelse(country == "Brazil" & city=="Sao Paulo" & venue=="Aeroanta", 1, checked),
venue = ifelse(venue=="Zepplin Rock", "Zeppelin Rock", venue),
city = ifelse(city=="San.De Campostela", "Santiago de Compostela", city),
x = ifelse(city=="Huntington" & venue=="Stone Monkey", -82.4201034, x),
y = ifelse(city=="Huntington" & venue=="Stone Monkey", 38.4272709, y),
checked = ifelse(city=="Huntington" & venue=="Stone Monkey", 1, checked))
# Correct country
othervariables <- othervariables %>%
mutate(country = ifelse((city=="Belfast" | city=="Derry"), "Northern Ireland", country),
country = ifelse(flsid=="FLS0970", "USA", country))
# Correct location of Queen's Hall, Belfast
othervariables <- othervariables %>%
mutate(x = ifelse(country == "Northern Ireland" & city=="Belfast" & (venue=="Queen's Hall" | venue=="Queen's University Mandela Hall"), -5.9374134, x),
y = ifelse(country == "Northern Ireland" & city=="Belfast" & (venue=="Queen's Hall" | venue=="Queen's University Mandela Hall"), 54.5846991, y),
checked = ifelse(country == "Northern Ireland" & city=="Belfast" & (venue=="Queen's Hall" | venue=="Queen's University Mandela Hall"), 1, checked))
# Correct location of Rototom
othervariables <- othervariables %>%
mutate(city = ifelse(venue=="Rototom", "Gaio di Spilimbergo", city))
# Correct venue of 1995 Copenhagen show
othervariables <- othervariables %>%
mutate(venue = ifelse(gid=="copenhagen-denmark-71095", "Rockmaskinen", venue),
x = ifelse(gid=="copenhagen-denmark-71095", 12.5994855, x),
y = ifelse(gid=="copenhagen-denmark-71095", 55.6737142, y))
# Correct venue of Loppen
othervariables <- othervariables %>%
mutate(x = ifelse(gid=="copenhagen-denmark-100700", 12.5973313, x),
y = ifelse(gid=="copenhagen-denmark-100700", 55.6740572, y))
# Correct venue of 1988 Nottingham show
othervariables <- othervariables %>%
mutate(x = ifelse(gid=="nottingham-england-112788", -1.1349991, x),
y = ifelse(gid=="nottingham-england-112788", 52.9558396, y))
# Correct venue name and location for 1995 quebec city show
othervariables <- othervariables %>%
mutate(venue = ifelse(gid=="quebec-city-qc-canada-92495", "Cégep Limoilou", venue))
othervariables <- othervariables %>%
mutate(x = ifelse(gid=="quebec-city-qc-canada-92495", -71.2283038, x),
y = ifelse(gid=="quebec-city-qc-canada-92495", 46.8305332, y))
# Correct venue name https://www.dischord.com/fugazi_live_series/campinas-brazil-81997
# Assampi = Associação de amigos do Parque Industrial
othervariables <- othervariables %>%
mutate(venue = ifelse(gid=="campinas-brazil-81997", "Assampi", venue))
# Correct venue name https://www.dischord.com/fugazi_live_series/joinville-brazil-81597
# Liga da Sociedade Joinvilense
othervariables <- othervariables %>%
mutate(venue = ifelse(gid=="joinville-brazil-81597", "Liga da Sociedade Joinvilense", venue))
# Correct venue name for 1998 quebec city show https://dischord.com/fugazi_live_series/quebec-city-qc-canada-72298
othervariables <- othervariables %>%
mutate(venue = ifelse(gid=="quebec-city-qc-canada-72298", "Centre des Loisirs Saint-Sacrement", venue))
# impute values where they are missing
meanattendance <- othervariables %>%
filter(is.na(tour)==FALSE) %>%
filter(is.na(attendance)==FALSE) %>%
group_by(year) %>%
summarise(meanattendance = mean(attendance)) %>%
ungroup()
othervariables <- othervariables %>%
filter(is.na(tour)==FALSE) %>%
left_join(meanattendance) %>%
mutate(attendance = ifelse(is.na(attendance)==TRUE,meanattendance,attendance))
othervariables <- othervariables %>%
select(-meanattendance)
othervariables <- othervariables %>%
relocate(checked, .after = year)
mydir <- getwd()
myinputdir <- paste0(mydir, "/inst/extdata/")
mydatadir <- paste0(mydir, "/data")
fls_venue_geocoding_update_filename <- paste0(myinputdir, "fls_venue_geocoding.csv")
# Update coordinates from geocoding file
fls_venue_geocoding_update <- read.csv(fls_venue_geocoding_update_filename, header=TRUE) %>%
select(country, city, venue, link_x, link_y, city_disambiguation, guess, unknown) %>%
filter(is.na(link_x)==FALSE) %>%
mutate(geocoding_check=1)
fls_venue_geocoding_update <- fls_venue_geocoding_update %>%
mutate(city_disambiguation = ifelse(nchar(city_disambiguation)>0,city_disambiguation,NA))
othervariables <- othervariables %>%
left_join(fls_venue_geocoding_update)
othervariables <- othervariables %>%
mutate(x = ifelse(is.na(link_x)==FALSE, link_x, x),
y = ifelse(is.na(link_y)==FALSE, link_y, y),
city = ifelse(is.na(city_disambiguation)==FALSE, city_disambiguation, city),
checked = ifelse(is.na(geocoding_check)==FALSE & is.na(guess)==TRUE & is.na(unknown)==TRUE, geocoding_check, checked))
othervariables <- othervariables %>%
select(-link_x, -link_y, -city_disambiguation, -geocoding_check, -guess, -unknown)
setwd(mydatadir)
othervariables <- othervariables %>%
group_by(gid) %>%
slice(1) %>%
ungroup()
save(othervariables, file="othervariables.rda")
save(releasesdatalookup, file="releasesdatalookup.rda")
save(songvarslookup, file="songvarslookup.rda")
save(Repeatr0, file="Repeatr0.rda")
setwd(mydir)
# process tags data -------------------------------------------------------
setwd(myinputdir)
fls_tags_name_recoded <- system.file("extdata", "fls_tags_name_recoded.csv", package = "Repeatr")
fls_tags_name_recoded <- read.csv(fls_tags_name_recoded)
fls_tags <- fls_tags_importer(myfilename = "fls_tags.txt")
fls_tags <- fls_tags %>%
mutate(name = str_to_lower(name))
fls_tags <- fls_tags %>%
left_join(fls_tags_name_recoded)
fls_tags <- fls_tags %>%
mutate(name = name_corrected)
fls_tags <- fls_tags %>%
select(-name_corrected)
fls_tags <- fls_tags %>%
rename(song = name)
fls_tags <- fls_tags %>%
mutate(album = ifelse(album == "20220218 40 Watt, Athens, GA, USA", "19930218 40 Watt, Athens, GA, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(album == "20010607 Archie Browning Centre, Victoria, BC, Canada", "20010706 Archie Browning Centre, Victoria, BC, Canada", album))
fls_tags <- fls_tags %>%
mutate(year = str_sub(album, 1, 4),
month = str_sub(album, 5, 6),
day = str_sub(album, 7, 8),
datestring = paste0(day, "/", month, "/", year))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "20/02/1988" , "19880220 Merrifield Community Center, Merrifield, VA, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "20/08/1994" , "19940820 Aeroanta, Sao Paulo, Brazil", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "24/09/1995" , "19950924 Cegep Limoilou, Quebec City, Quebec, Canada", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "22/07/1998" , "19980722 Centre de Loisirs, Quebec City, QC, Canada", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "11/02/1990" , "19900211 Studio 10, Baltimore, MD, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "06/09/1991" , "19910906 Desert Fest, Jawbone Canyon, CA, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "14/11/1998" , "19981114 University of Wisconsin, Fire Room, Eau Claire, WI, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "03/03/1999" , "19990303 Cal State University Shurmer Gym, Chico, CA, USA", album))
fls_tags <- fls_tags %>%
mutate(album = ifelse(datestring == "25/04/2001" , "20010425 9:30 Club, Washington, DC, USA", album))
fls_tags <- fls_tags %>%
mutate(date = as.Date(datestring, "%d/%m/%Y"))
fls_tags <- fls_tags %>%
rowwise() %>%
mutate(firstcomma = unlist(gregexpr(',', album))[1])
fls_tags <- fls_tags %>%
rowwise() %>%
mutate(secondcomma = unlist(gregexpr(',', album))[2])
fls_tags <- fls_tags %>%
rowwise() %>%
mutate(lastcomma = tail(unlist(gregexpr(',', album)), n=1))
fls_tags <- fls_tags %>%
mutate(stringlength = nchar(album))
fls_tags <- fls_tags %>%
mutate(venue = str_sub(album, 10, firstcomma-1))
fls_tags <- fls_tags %>%
filter(venue!="Mayfaur")
fls_tags <- fls_tags %>%
mutate(city = str_sub(album, firstcomma + 2, secondcomma-1))
fls_tags <- fls_tags %>%
mutate(country = str_sub(album, lastcomma + 2, stringlength))
fls_tags <- fls_tags %>%
mutate(state = ifelse(country=="USA", str_sub(album, lastcomma-2, lastcomma-1),""))
fls_tags <- fls_tags %>%
select(track, album, song, duration, seconds, date, venue, city, state, country)
date_gid <- othervariables %>%
select(date, gid)
fls_tags <- fls_tags %>%
left_join(date_gid)
fls_tags <- fls_tags %>%
filter(venue!="Van Hall" | gid!="gent-belgium-101688")
fls_tags <- fls_tags %>%
filter(venue!="Democrazy" | gid!="amsterdam-netherlands-101688")
fls_tags <- fls_tags %>%
mutate(song = ifelse(gid=="peoria-il-usa-100995" & song=="dance rap", "interlude 4", song))
fls_tags_show <- fls_tags %>%
group_by(date, venue, city, state, country, album, gid) %>%
summarize(seconds = sum(seconds)) %>%
mutate(duration = seconds_to_period(seconds)) %>%
ungroup()
fls_tags_show <- fls_tags_show %>%
select(date, venue, city, state, country, album, gid, duration, seconds)
setwd(mydatadir)
save(fls_tags, file = "fls_tags.rda")
save(fls_tags_show, file = "fls_tags_show.rda")
setwd(mydir)
# Select the most relevant columns -------
Repeatr1 <- subset(Repeatr0, select = -c(V2, V4, V5, V6, V7, V8, V9))
names(Repeatr1)
# Define gig id -----------------------------------------------------------
names(Repeatr1)[names(Repeatr1) == "V1"] <- "gid"
# Define date variables ----------------------------------------------------
names(Repeatr1)[names(Repeatr1) == "V3"] <- "date"
Repeatr1 <- Repeatr1 %>%
mutate(date = as.Date(date, "%d/%m/%Y"))
Repeatr1 <- Repeatr1 %>%
mutate(year = year(date)) %>%
relocate(year, .after=date)
Repeatr1 <- Repeatr1 %>%
mutate(month = month(date)) %>%
relocate(month, .after=year)
Repeatr1 <- Repeatr1 %>%
mutate(day = day(date)) %>%
relocate(day, .after=month)
# Rename variables to make reshaping the data easier ----------------------
myv <- 10
for(mysong in 1:44) {
myinitialname <- paste0("V", myv)
mynewname <- paste0("song.", mysong)
names(Repeatr1)[names(Repeatr1) == myinitialname] <- mynewname
myv <- myv + 1
}
Repeatr1$nchar <- nchar(Repeatr1$song.1)
Repeatr1 <- Repeatr1 %>%
filter(nchar>0)
Repeatr1$nchar <- NULL
# Reshape to long format with 1 row per song ------------------------------
Repeatr1 <- reshape(data = Repeatr1
, direction = "long"
, varying = 6:44
, idvar = "gid"
)
# Define song number ------------------------------------------------------
names(Repeatr1)[names(Repeatr1) == "time"] <- "song_number"
Repeatr1 <- Repeatr1 %>%
arrange(gid, song_number)
Repeatr1 <- Repeatr1 %>%
mutate(song = str_to_lower(song))
Repeatr1$nchar <- nchar(Repeatr1$song)
Repeatr1 <- Repeatr1 %>%
filter(nchar>0)
Repeatr1$nchar <- NULL
# add on outros
Repeatr1_outro <- fls_tags %>%
filter(song=="outro") %>%
select(gid, date, track, song) %>%
rename(song_number = track) %>%
mutate(song_number = as.numeric(song_number))
Repeatr1_outro <- Repeatr1_outro %>%
mutate(date = as.Date(date, "%d/%m/%Y"))
Repeatr1_outro <- Repeatr1_outro %>%
mutate(year = year(date)) %>%
relocate(year, .after=date)
Repeatr1_outro <- Repeatr1_outro %>%
mutate(month = month(date)) %>%
relocate(month, .after=year)
Repeatr1_outro <- Repeatr1_outro %>%
mutate(day = day(date)) %>%
relocate(day, .after=month)
Repeatr1 <- rbind.data.frame(Repeatr1, Repeatr1_outro)
# Recode variants of song titles to the main song title -------------------
Repeatr1 <- Repeatr1 %>%
mutate(song = str_replace(song, " instrumental", ""))
Repeatr1 <- Repeatr1 %>%
mutate(song = str_replace(song, " acapella", ""))
Repeatr1 <- Repeatr1 %>%
mutate(song = str_replace(song, " drum and bass jam", ""))
Repeatr1 <- Repeatr1 %>%
mutate(song = ifelse(song=="bed for the scraping (continued)", "bed for the scraping", song))
Repeatr1 <- Repeatr1 %>%
mutate(song = ifelse(song=="promises bit soundcheck", "promises", song))
Repeatr1 <- Repeatr1 %>%
mutate(song = ifelse(song=="promises coda", "promises", song))
Repeatr1 <- Repeatr1 %>%
mutate(song = ifelse(song=="provisional medley", "provisional", song))
Repeatr1 <- Repeatr1 %>%
mutate(song = ifelse(song=="the argument", "argument", song))
# define track types: intros, interludes, sound checks -----------------------------------------------------------------
Repeatr1$tracktype <- 1
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("interlude", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("encore", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("intro", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("track", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("remarks", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("ice cream", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("outside", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("sound check", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("soundcheck", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("crowd", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("outro", song)==TRUE, 0, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("untitled", song)==TRUE, 0, tracktype))
# Filter to remove unreleased songs or improvised one-offs ---------------------------------------
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("heart on my chest", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("lock dug", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("nedcars", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("noisy dub", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("nsa", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("set the charges", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("she is blind", song)==TRUE, 2, tracktype))
Repeatr1 <- Repeatr1 %>%
mutate(tracktype=ifelse(grepl("surf tune", song)==TRUE, 2, tracktype))
# Summarise the data to check frequency counts for all songs --------------
mycount <- Repeatr1 %>%
filter(tracktype==1) %>%
group_by(song) %>%
summarise(count= n()) %>%
ungroup()
mycount <- mycount %>%
arrange((song))
mycount <- mycount %>% mutate(songid = row_number())
mycount <- mycount %>% relocate(songid)
# Create lookup table to go from song id to song title --------------
songidlookup <- mycount
songidlookup$count <- NULL
setwd(mydatadir)
save(songidlookup, file="songidlookup.rda")
setwd(mydir)
# Redefine song index in terms of the included songs ----------------------
Repeatr1 <- Repeatr1 %>%
arrange(gid, song_number)
Repeatr1a <- Repeatr1 %>%
filter(tracktype==1) %>%
group_by(gid) %>%
mutate(song_number = row_number()) %>%
ungroup()
Repeatr1a <- Repeatr1a %>%
mutate(first_song = ifelse(song_number==1, 1, 0))
Repeatr1a <- Repeatr1a %>%
group_by(gid) %>%
mutate(number_songs = n()) %>%
mutate(last_song = ifelse(song_number==number_songs, 1, 0)) %>%
ungroup()
Repeatr1a <- Repeatr1a %>%
select(gid, song, number_songs, first_song, last_song)
Repeatr1b <- Repeatr1a %>%
group_by(gid) %>%
slice(1) %>%
select(gid, number_songs) %>%
ungroup()
Repeatr1a <- Repeatr1a %>%
select(-number_songs)
Repeatr1 <- Repeatr1 %>%
left_join(Repeatr1b)
Repeatr1 <- Repeatr1 %>%
left_join(Repeatr1a)
Repeatr1 <- Repeatr1 %>%
left_join(songidlookup)
# add additional variables for potential use in the choice modelling
songvarslookup <- songvarslookup %>% select(songid, releaseid, track_number, instrumental, vocals_picciotto, vocals_mackaye, vocals_lally, duration_seconds)
Repeatr1 <- Repeatr1 %>%
left_join(songvarslookup)
Repeatr1 <- Repeatr1 %>% left_join(releasesdatalookup)
# Save disaggregate data -----------------------------------
Repeatr1 <- Repeatr1 %>%
select(gid, date, year, month, day, tracktype, song_number, songid, song, number_songs, first_song, last_song, releaseid, release, track_number, instrumental, vocals_picciotto, vocals_mackaye, vocals_lally, duration_seconds) %>%
arrange(date, song_number)
# remove duplicates
Repeatr1 <- Repeatr1 %>%
group_by(gid, song_number) %>%
slice(1) %>%
ungroup()
setwd(mydatadir)
save(Repeatr1, file = "Repeatr1.rda")
setwd(mydir)
# calculate cumulative rendition counts -----------------------------------
mydf <- Repeatr1 %>%
filter(tracktype==1) %>%
select(date, song)
mydf <- mydf %>%
group_by(date, song) %>%
summarize(count=n()) %>%
ungroup()
mydf_wide <- mydf %>%
pivot_wider(names_from = song, values_from = count, values_fill = 0)
mydf_wide2 <- mydf_wide
number_columns <- ncol(mydf_wide2)
for(colindex in 2:number_columns) {
mydf_wide2[,colindex] <- cumsum(mydf_wide2[,colindex])
}
mydf_long <- mydf_wide2 %>%
pivot_longer(!date, names_to = "song", values_to = "count") %>%
filter(count>0)
releases_lookup <- Repeatr1 %>%
group_by(song, release) %>%
summarize(count = n()) %>%
ungroup() %>%
select(song, release)
mydf_long <- mydf_long %>%
left_join(releases_lookup)
cumulative_song_counts <- mydf_long %>%
select(date, song, release, count)
cumulative_song_counts <- cumulative_song_counts %>%
mutate(release = tolower(release)) %>%
left_join(releasesdatalookup) %>%
select(date, song, release, count, releasedate)
setwd(mydatadir)
save(cumulative_song_counts, file = "cumulative_song_counts.rda")
setwd(mydir)
# calculate cumulative duration counts -----------------------------------
song_songid <- Repeatr1 %>%
filter(tracktype==1) %>%
group_by(song, songid) %>%
slice(1) %>%
select(song, songid) %>%
ungroup()
mydf <- fls_tags %>%
select(song, seconds) %>%
mutate(minutes = round(seconds/60, digits = 2)) %>%
select(-seconds) %>%
left_join(song_songid) %>%
filter(is.na(songid)==FALSE) %>%
select(-songid)
mydf <- mydf %>%
group_by(minutes, song) %>%
summarize(count=n()) %>% ungroup()
mydf_wide <- mydf %>%
pivot_wider(names_from = song, values_from = count, values_fill = 0)
mydf_wide2 <- mydf_wide
number_columns <- ncol(mydf_wide2)
for(colindex in 2:number_columns) {
mydf_wide2[,colindex] <- cumsum(mydf_wide2[,colindex])
}
mydf_long <- mydf_wide2 %>%
pivot_longer(!minutes, names_to = "song", values_to = "count") %>%
filter(count>0)
releases_lookup <- Repeatr1 %>%
group_by(song, release) %>%
summarize(count = n()) %>%
ungroup() %>%
select(song, release) %>%
filter(song!="crowd")
mydf_long <- mydf_long %>%
left_join(releases_lookup)
cumulative_duration_counts <- mydf_long %>%
select(minutes, song, release, count) %>%
mutate(release = ifelse(is.na(release)==TRUE, "unreleased", release))
setwd(mydatadir)
save(cumulative_duration_counts, file = "cumulative_duration_counts.rda")
setwd(mydir)
# calculate duration summary -----------------------------------
song_songid <- Repeatr1 %>%
filter(tracktype==1) %>%
group_by(song, songid) %>%
slice(1) %>%
select(song, songid) %>%
ungroup() %>%
filter(song!="crowd")
duration_summary <- fls_tags %>%
group_by(song) %>%
summarize(renditions = n(),
minutes_min = round(min(seconds)/60, digits = 2),
minutes_median = round(median(seconds)/60, digits = 2),
minutes_max = round(max(seconds)/60, digits = 2),
minutes_mean = round(mean(seconds)/60, digits = 2),
minutes_sd = round(sd(seconds)/60, digits = 2)) %>%
ungroup() %>%
left_join(song_songid) %>%
filter(is.na(songid)==FALSE) %>%
select(-songid)
duration_summary <- duration_summary %>%
mutate(minutes_total = round(renditions*minutes_mean, digits = 2))
setwd(mydatadir)
save(duration_summary, file = "duration_summary.rda")
setwd(mydir)
# Played with data --------------------------------------------------------
played_with_file <- system.file("extdata", "gid_fls_id_played_with.csv", package = "Repeatr")
played_with <- read.csv(played_with_file)
played_with <- played_with %>%
mutate_if(is.character, utf8::utf8_encode)
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="bielefeld-germany-103188", "Pygmies", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="rome-italy-102790", "Ratos de Porão", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="ann-arbor-mi-usa-62390", "Ward, Phünhögg", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="bergara-spainbasque-101099", "Half Foot Outside, Lisabö", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="jawbone-canyon-ca-usa-90691", "Pop Defect, Sandy Duncan’s Eye, The Paper Tulips, The Offspring, The Fumes, This Great Religion, TVTV$", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="washington-dc-usa-101589", "Fidelity Jones, Tiik, Lungfish, Juliana Experience, Weatherhead, Moss Icon, Dog Born Society, Choke, Cabal, All White Jury, Daryl Stover, Caroline Ely, 200 Stitches, Transilience, Neverman", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(gid=="belo-horizonte-brazil-81594", "Stigmata, Jorge Cabeleira, Daizy Down, Oz, Intense Manner of Living, Virna Lisi", played_with))
played_with<-played_with %>%
separate_rows(played_with, sep=",")
played_with<-played_with %>%
separate_rows(played_with, sep="&")
played_with<-played_with %>%
separate_rows(played_with, sep="amp;")
played_with <- played_with %>%
mutate(played_with = str_trim(played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Shudder To Think", "Shudder to Think", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Adventures of Immortality", "Adventures In Immortality", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Assault Frontali", "Assalti Frontali", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Assaulti Frontali", "Assalti Frontali", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Darkness At Noon", "Darkness at Noon", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Dirty Districts", "Dirty District", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Genbaku Onanisu", "Genbaku Onanies", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="God Is My Co-Pulot", "God Is My Co-Pilot", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Metamatix", "Metamatics", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Missonarios", "Missionarios", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Nation Of Ulysses", "Nation of Ulysses", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Sandy Duncan's Eye", "Sandy Duncan’s Eye", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Seven Souix", "Seven Sioux", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Thatcher On Acid", "Thatcher on Acid", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Vampire Lesbos", "Vampire Lezbos", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Int. Noise Conspiracy", "The International Noise Conspiracy", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Victim s Family", "Victim's Family", played_with))
played_with <- played_with %>%
mutate(played_with = ifelse(played_with=="Offspring", "The Offspring", played_with))
played_with <- played_with %>%