-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_MainAnalysis_Timelines_Regression_Duration.Rmd
1752 lines (1305 loc) · 74.5 KB
/
01_MainAnalysis_Timelines_Regression_Duration.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
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
---
title: "Collective Emotions during the Covid-19 Outbreak: temporal emotion dynamics"
subtitle: "Descriptive statistics, timelines, regressions 5 weeks after outbreak, duration of changes"
author: "Hannah Metzler & David Garcia"
output:
pdf_document:
df_print: kable
keep_tex: true
url_colour: blue
always_allow_html: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message=FALSE, warning=FALSE)
Sys.setlocale("LC_ALL", 'en_US.UTF-8')
options(scipen=10)
```
```{r, libraries, results='hide'}
library(tidyverse)
library(scales) #for figures
library(gridExtra) #for figures
library(lme4) #for models
library(cowplot) #for figures
library(ggrepel)#for overlapping labels in figures
library(broom.mixed) #for tidy model output tables
library(sjPlot) #for exporting model tables
#colours in graphics
library(viridis)
library(RColorBrewer)
#functions for data processing, plotting, and settings
source("scripts/functions_figure_settings.R")
```
```{r, data processing, results=FALSE, eval=FALSE}
#data processing steps that take a few hours, since they include calculation of CIs, load data file CountriesData.csv instead (next section)
#source("scripts/process_data.R")
```
```{r, load data, results=FALSE, cache=TRUE}
all <- read.csv("data_main/CountriesData.csv")
all <- all %>%
mutate(date = as.Date(date)) %>%
mutate(continent = dplyr::recode(country2, Austria = "Europe", Germany = "Europe", Switzerland = "Europe",
Italy = "Europe", France = "Europe", Spain = "Europe",
BelgiumDutch="Europe", Netherlands="Europe", "UK" ="Europe", Ireland="Europe",
USA="North America", CanadaEnglish="North America",
Australia="Australia", "NewZealand" ="Australia",
Chile= "South America", Ecuador= "South America", Peru= "South America", Mexico = "South America"))
#load dates of nationwide broad social distancing measures in each country (for the timeline figures)
measures <- read.csv2('data_main/SocialDistancingMeasures.csv') %>%
mutate(social_distancing = as.Date(social_distancing, format = '%d/%m/%y')) %>%
select(country, social_distancing)
#light data processing steps, like calculating periods above/below baseline with the data loaded above
source("scripts/process_data_light.R")
#measure stringency
ds0= read.csv('data_main/OxCGRT_stringencyindex.csv')
ds = ds0 %>%
mutate(Date = as.Date(as.character(Date),format="%Y%m%d")) %>%
filter(Date < as.Date("2020-04-30")) %>%
filter(CountryName %in% c(as.character(unique(all$country2)),'New Zealand', 'Canada', "Belgium", 'United States', 'United Kingdom')) %>%
droplevels() %>%
#rename variables
rename(country2 = "CountryName",
date = Date,
country = CountryCode,
stringency = StringencyIndex,
confirmed = ConfirmedCases) %>%
filter(RegionName == '') %>% #select only whole country index, not by region
#rename country code and name so it fits our dataset
mutate(country2 = recode(country2, "United Kingdom" ="UK","United States"="USA")) %>%
select(country, country2, date, stringency)
```
# Descriptive statistics
## Across all countries and entire time period
Mean, SD, and 95% CI around the mean across the entire time period, and mean for the baseline period (2019).
```{r}
all %>%
group_by(wordlist) %>%
summarize(meanpr = mean(pr), sdpr = sd(pr),meancilow = mean(prlow), meancihigh = mean(prhigh),
meanbl = mean(bl))
```
## Sample size and mean per day per country
```{r}
tweets_per_country <- all %>%
group_by(country2) %>%
filter(wordlist=="anger") %>%
summarize(milliontweets = round(sum(as.numeric(tot_n)/1000000), 2),
meantweetsperday = round(mean(as.numeric(tot_n)), 2)) %>%
ungroup()
tweets_per_country
write.csv2(tweets_per_country, 'output/tweet_sample_size_country.csv',row.names=F)
```
## Total sample size
```{r}
tweets_per_country %>%
summarise(ntotal_mio = sum(milliontweets),
min = min(milliontweets),
max = max(milliontweets))
```
\newpage
## Maximal change after outbreak compared to baseline
Peak changes (1) for each emotion in each country, and (2) their median and range across countries (i.e. from country with lowest to country with highest peak).
```{r}
#date with 30 cases as threshold for each country, then look at the maximal value after that date
casesabove30 <- all$confirmed>=30
peaks <- all %>%
mutate(casesabove30 = ifelse(confirmed>=30, 1, 0)) %>%
filter(casesabove30 ==1) %>% #only days after this date
group_by(wordlist, country2) %>%
summarize(max_change = max(100*(pr-bl)/bl))
peaks
peaks %>% group_by(wordlist) %>%
summarize(median_max = median(max_change),
lowest_max = min(max_change),
highest_max = max(max_change))
```
## Choosing example countries for Figure 1
Rank by number of confirmed cases:
```{r}
all %>%
filter(date == as.Date("2020-04-15")) %>%
filter(wordlist == "anxiety") %>%
arrange(confirmed) %>%
select(date, country2, confirmed)
```
\newpage
## Table S1. Average proportions per country (grand mean and standard deviations across analyzed time period from January 2019 to April 2020)
```{r}
dataperiods <- read.csv("data_main/AfterOutbreak-Weeks-5.csv")
p_country <- dataperiods %>%
mutate(country = dplyr::recode(country, BelgiumDutch="Belgium", CanadaEnglish="Canada", NewZealand ="New Zealand")) %>%
mutate(Emotion = recode(wordlist, anger = "Anger", anxiety = "Anxiety", positive = "Positive", sadness = "Sadness")) %>%
rename(Country = country) %>%
group_by(Emotion, Country) %>%
mutate(pr = emo_n/tot_n) %>%
summarize("Mean %" = round(100*mean(pr),2), SD = round(100*sd(pr),2))
p_country
write.csv2(p_country, "output/TableS1_percentage_country.csv", row.names=F)
```
\newpage
## Table S2. Average proportions per country for the baseline period
```{r}
dataperiods <- read.csv("AfterOutbreak-Weeks-5.csv")
p_country_baseline <- dataperiods %>%
mutate(country = dplyr::recode(country, BelgiumDutch="Belgium", CanadaEnglish="Canada", NewZealand ="New Zealand")) %>%
mutate(Emotion = dplyr::recode(wordlist, anger = "Anger", anxiety = "Anxiety", positive = "Positive", sadness = "Sadness")) %>%
mutate(period = dplyr::recode(period, "Week 1" = "Outbreak", "Week 2" = "Outbreak", "Week 3" = "Outbreak", "Week 4" = "Outbreak", "Week 5" = "Outbreak", baseline = "Baseline", control = "Control")) %>%
rename(Country = country, Period = period) %>%
group_by(Emotion, Country, Period) %>%
mutate(pr = emo_n/tot_n) %>%
summarize("Mean %" = round(100*mean(pr),2)) %>%
pivot_wider(names_from = c(Emotion, Period), values_from = "Mean %") %>%
# relocate(c("Anger_Baseline", "Anger_Outbreak", "Positive_Baseline", "Positive_Outbreak"), .after = "Sadness_Outbreak")
relocate(c("Anger_Baseline", "Anger_Control","Anger_Outbreak", "Positive_Baseline", "Positive_Control", "Positive_Outbreak"), .after = "Sadness_Outbreak") %>%
ungroup()
p_country_baseline
# p_country_baseline %>%
# summarize_if(is.numeric, range)
write.csv(p_country_baseline, "output/TableS2_percentage_baseline__control_outbreak.csv", row.names=F)
```
\newpage
# Timeseries of cases in all countries
In Latin America, cases only start to increase later than in Europe and North America.
```{r, cases in all countries}
#colours
colscountries = c(brewer.pal(11, "PRGn")[c(1:4,8:11)], brewer.pal(11, "RdYlBu")[c(1:5,8,10,11)], brewer.pal(11, "PiYG")[c(2,4)])
#per continent colour, log scale
ggplot(data = filter(all, date > as.Date("2020-02-01") & date <as.Date("2020-04-15")),
aes(x = date, y =log(confirmed), group=country, colour=continent)) +
geom_line()+
theme_bw()+ theme(text=element_text(size=12), axis.text=element_text(size=labelsize), legend.title=element_blank(),
legend.position="right")+
ylab("Confirmed cases (log)") + xlab("")+
scale_colour_manual(values=colscountries)+
ggtitle("Cases on log scale - all countries")
#per country colour, without the US
ggplot(data = filter(all, date > as.Date("2020-02-01") & date <as.Date("2020-04-15") & country2!="USA"),
aes(x = date, y =(confirmed), colour=country2)) +
geom_line()+
theme_bw()+ theme(text=element_text(size=12), axis.text=element_text(size=labelsize), legend.title=element_blank(),
legend.position="right")+
ylab("Confirmed cases") + xlab("")+ggtitle("Cases on natural scale - all countries except the US")+
scale_colour_manual(values=colscountries)
```
# Time series of total tweets and unique authors
```{r, total tweets, fig.height=8, fig.width=7}
#colours
colscountries = c(brewer.pal(11, "PRGn")[c(1:4,8:11)], brewer.pal(11, "RdYlBu")[c(1:5,8,10,11)], brewer.pal(11, "PiYG")[c(2,4)])
# read in twitter follower, retweets, authors data for example countries
df = read.csv('data_main/TwitterChange.csv') %>%
mutate(date=as.Date(date),
country = as.factor(country),
Twitter = as.factor(Twitter))
dfchange = df %>%
filter(date > as.Date('2020-01-01')) %>%
mutate(pre_post = if_else(date < '2020-03-01', "Jan-Feb", 'Mar-Apr')) %>%
group_by(pre_post, country) %>%
summarise(mean_change = mean((value-bl)/bl),
max_change = max((value-bl)/bl)) %>%
ungroup() %>%
filter(pre_post =="Mar-Apr")
#plot
ggplot(filter(df, date > as.Date("2019-12-31") & date < as.Date("2020-04-20")))+
geom_line(aes(x=date, y=100*(value-bl)/bl, colour=country))+ #
facet_wrap(~Twitter, ncol = 1)+
theme_bw()+ theme(text=element_text(size=axisfontsize), axis.text=element_text(size=labelsize, angle=45, hjust=1),
axis.title.x = element_blank(),
legend.title=element_blank(), legend.position="bottom",
plot.margin = margin(0.5, 0.5, 0.5, 0.5, "cm"))+
ylab("% change over 2019 baseline") +
scale_x_date(date_breaks="1 month", date_labels = "%b")+
scale_colour_manual(values=colscountries)+
geom_hline(yintercept = 0, colour = "grey50") #mean line
ggsave('figures/twitter_change_allcountries.pdf', height=8, width=8)
```
Mean change: `r mean(dfchange$max_change)[1]`
# Legends for timeline plots
* In all timeline plots below, the black dashed line indicates the onset of nationwide social distancing measures that concern the general population, rather than just some small subgroups (e.g. prisons, retirement homes, universities). Such general measures include closures of bars, restaurants, schools, kindergardens, stay at home orders, restrictions on the usage of public transport etc.
* The grey rectangles at the bottom of each figure indicate the time periods we analysed in logistic regressions, the control period from 15 January to 14 February, and 5 one-week periods starting from the outbreak of Covid-19 in each country. The outbreak was defined as the day on which the number of confirmed cases reached 30.
* The last figure (Figure 2) shows the regression coefficients for each of these six periods (control, and week 1 to 5).
# Italy
```{r, Italy, fig.width=6, fig.height=4.5, cache=TRUE}
#only 2020
all %>%
filter(country=="ita") %>%
filter(date > as.Date("2020-01-01")) -> df
firstcase <- df %>%
filter(confirmed > 0) %>%
slice(1) %>%
select(date)
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -25
plotlines <- plotTS(df, mode="percent", title="Italy", limits=NULL)+
#lockdown line and label
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = as.numeric(firstcase), colour = "grey", linetype=2) #add first case date to label the high peak (all other peaks in Figure 1 have labels too)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
# ggsave('figures/EmotionTimelines2020_Italy.pdf', width=8, height=6, dpi=300)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Italy", limits=c(-30,100))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = as.numeric(firstcase), colour = "grey", linetype=2)+ #add first case date to label the high peak (all other peaks in Figure 1 have labels too)
theme(axis.title.y.right = element_blank())
plotita <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh))
```
\newpage
# Spain
Events
* Blue: Parliament election of prime minister in polarized climate 2020-01-05
```{r, Spain, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="esp") %>%
filter(date > as.Date("2020-01-01")) -> df
#peak days
election <- as.Date("2020-01-05")
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -15; yt = -12.7
plotlines <- plotTS(df, mode="percent", title="Spain", limits=NULL, factor = 6.5) +
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = election, colour = colnormal, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Spain", limits=c(-15,45), factor = 6.5) +
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = election, colour = colnormal, linetype=2)+
theme(axis.title.y.right = element_blank())
plotesp <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# France
```{r, France, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="fra") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -12; yt = -10.5
plotlines <- plotTS(df, mode="percent", title="France", limits=NULL, factor=4)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_label(label="Nationwide social distancing", x=lockdown, y = 20, colour = collockdown, size = 4)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
# plot for paper
plotlines <- plotTS(df, mode="percent", title="France", limits=c(-12,30), factor=4)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(legend.position="none")
plotfra <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Germany
Events
* Red: Terrorist attack in Hanau on 2020-02-25
```{r, Germany, fig.width=10, fig.height=6, cache=TRUE}
#all emotions for Germany
#important dates Germany:
hanau <- as.Date("2020-02-19")#right extremist terrorist attack in Hanau
all %>%
filter(country=="ger") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -25
plotlines <- plotTS(df, mode="percent", title="Germany", limits=NULL)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
geom_label(label="terrorist attack Hanau", x=hanau-9, y = 70, colour = colterror, size = 4)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_label(label="Nationwide social distancing", x=lockdown, y = 80, colour = collockdown, size = 4)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Germany", limits=c(-30,100))+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
geom_label(label="terrorist attack Hanau", x=hanau-9, y = 70, colour = colterror, size = 4)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_label(label="Nationwide social distancing", x=lockdown, y = 80, colour = collockdown, size = 4)+
theme(axis.title.y.left = element_blank())
plotger <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Austria
Events
* Red: Terrorist attack in Hanau on 2020-02-25
```{r, Austria, fig.width=6, fig.height=4.5, cache=TRUE}
all %>%
filter(country=="aut") %>%
filter(date > as.Date("2020-01-01")) -> df
firstcase <- df %>%
filter(confirmed > 0) %>%
slice(1) %>%
select(date)
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -40; yt = -35
plotlines <- plotTS(df, mode="percent", title="Austria", limits=NULL)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = as.numeric(firstcase), colour = "grey", linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Austria", limits=c(-40,100))+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.right = element_blank(), legend.position="none")
plotaut <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
# cowplot::plot_grid(plotita, plotaut, ncol=2, nrow=1)
# ggsave('figures/EmotionTimelines_Ita&Aut_with_stringency.pdf', width=12, height=4)
```
\newpage
# Switzerland (German)
```{r, Switzerland, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="che") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -40; yt = -35
plotlines <- plotTS(df, mode="percent", title="Switzerland", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
geom_vline(xintercept = as.numeric(firstcase), colour = "grey", linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Switzerland", limits=c(-40,100))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
theme(axis.title.y.left = element_blank(), legend.position="none")
plotche <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# UK
```{r, UK, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="uk") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -28; yt = -24
plotlines <- plotTS(df, mode="percent", title="United Kingdom", limits=NULL, factor=12)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="United Kingdom", limits=c(-30,95), factor=12)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.right = element_blank(), legend.position="none")
plotuk <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
# Ireland
```{r, Ireland, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="ire") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -28; yt = -24
plotlines <- plotTS(df, mode="percent", title="Ireland", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Ireland", limits=c(-30,95))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.left = element_blank(), legend.position="none")
plotire <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# The Netherlands
```{r, Netherlands, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="net") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -25
plotlines <- plotTS(df, mode="percent", title="The Netherlands", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="The Netherlands", limits=c(-30,100))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2) +
theme(axis.title.y.right = element_blank(), legend.position="none")
plotnet <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Belgium (Dutch)
```{r, Belgium, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="beldutch") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -25
plotlines <- plotTS(df, mode="percent", title="Belgium (Dutch)", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Belgium (Dutch)", limits=c(-30,100))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = hanau, colour = colterror, linetype=2)+
theme(axis.title.y.left = element_blank(), legend.position="none")
plotbel <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl))
```
\newpage
# USA
Events
* Green: USA kills Iraqi military commander Soleimani on 2020-01-03
* Purple: Death of Kobe Bryant on 2020-01-26
* Blue: Super Bowl annual chamiponship of the National Football League (NFL) on 2020-02-03. Large sports events are usually linked to an increase of various emotions, not just anxiety, so it is likely that we will see a similar increase when analyzing other emotions.
* Black: date where the first state implements some form of lockdown 2020-03-19, the last state follows on 2020-04-07
```{r, USA, fig.width=10, fig.height=6, cache=TRUE}
#all emotions for USA
#important dates USA:
soleimani <- as.Date("2020-01-03")# 2020-01-03 #USA kills Iraqi military commander Soleimani
superbowl <- as.Date("2020-02-03") #sport event
kobe <- as.Date("2020-01-26") #sport event
all %>%
filter(country=="usa") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date("2020-03-19") #as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -15; yt = -12.7
plotlines <- plotTS(df, mode="percent", title="USA", limits=NULL, factor=7.5) +
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
#individual US events
geom_vline(xintercept = soleimani, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = superbowl, colour = colnormal, linetype=2)+
geom_vline(xintercept = kobe, colour = colcatast, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
# ggsave('figures/EmotionTimelines2020_USA.pdf', width=8, height=6, dpi=300)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
# #plot for paper
plotlines <- plotTS(df, mode="percent", title="USA", limits=c(-15,45), factor=7.5) +
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = soleimani, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = superbowl, colour = colnormal, linetype=2)+
geom_vline(xintercept = kobe, colour = colcatast, linetype=2)+
theme(axis.title.y.left = element_blank())
plotusa <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
```
\newpage
# Canada
Events
* Green: USA kills Iraqi military commander Soleimani on 2020-01-03
* Purple: Death of Kobe Bryant on 2020-01-26
* Blue: Super Bowl annual chamiponship of the National Football League (NFL) on 2020-02-03. Large sports events are usually linked to an increase of various emotions, not just anxiety, so it is likely that we will see a similar increase when analyzing other emotions.
* Black: date where 90% of US population under some form of lockdown, first state on 2020-03-19, last state on 2020-04-07
```{r, Canada, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="can") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -26
plotlines <- plotTS(df, mode="percent", title="Canada", limits=NULL, factor=12)+
geom_vline(xintercept = soleimani, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = superbowl, colour = colnormal, linetype=2)+
geom_vline(xintercept = kobe, colour = colcatast, linetype=2)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for the paper
plotlines <- plotTS(df, mode="percent", title="Canada", limits=c(-30,80), factor=12)+
geom_vline(xintercept = soleimani, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = superbowl, colour = colnormal, linetype=2)+
geom_vline(xintercept = kobe, colour = colcatast, linetype=2)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.right = element_blank(), legend.position="none")
plotcan <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Australia
```{r, Australia, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="aus") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -26
plotlines <- plotTS(df, mode="percent", title="Australia", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
plotlines <- plotTS(df, mode="percent", title="Australia", limits=c(-30,80))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.left = element_blank(), legend.position="none")
plotaus <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# New Zealand
```{r, New Zealand, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="nzl") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -26
plotlines <- plotTS(df, mode="percent", title="New Zealand", limits=NULL, factor=20)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="New Zealand", limits=c(-30,80), factor=20)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.right = element_blank(), legend.position="none")
plotnzl <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Chile
Events
* Green 1: Peak associated with civil protests against increased cost of living, privatisation and social inequality (https://en.wikipedia.org/wiki/2019%E2%80%932020_Chilean_protests).
* Green 2: Protests against violence against women
```{r, Chile, fig.width=10, fig.height=6, cache=TRUE}
#events
chileprotests <- as.Date("2020-01-29")
womensday <- as.Date("2020-03-08")
all %>%
filter(country=="chl") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -26
plotlines <- plotTS(df, mode="percent", title="Chile", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = chileprotests, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = womensday, colour = colpublicneg, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Chile", limits=c(-30,80))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = chileprotests, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = womensday, colour = colpublicneg, linetype=2)+
theme(axis.title.y.left = element_blank(), legend.position="none")
plotchl <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Ecuador
```{r, Ecuador, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="ecu") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -30; yt = -26
plotlines <- plotTS(df, mode="percent", title="Ecuador", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Ecuador", limits=c(-30,80))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.left= element_blank(), legend.position="none")
plotecu <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Peru
```{r, Peru, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="per") %>%
filter(date > as.Date("2020-01-01")) -> df
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -25; yt = -22
plotlines <- plotTS(df, mode="percent", title="Peru", limits=NULL, factor=7)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Peru", limits=c(-25,50), factor=7)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
theme(axis.title.y.right= element_blank(), legend.position="none")
plotper <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Mexico
Events
* Green: Protests against violence against women after the murder of Ingrid Escamilla and Fátima Aldrighett
```{r, Mexico, fig.width=10, fig.height=6, cache=TRUE}
all %>%
filter(country=="mex") %>%
filter(date > as.Date("2020-01-01")) -> df
womenviolence <- as.Date("2020-02-18")
strike <- as.Date("2020-03-09")
#dates for lockdown and testing periods
lockdown <- as.Date(measures$social_distancing[measures$country==unique(df$country)])
date1 <- as.Date(df$date[df$confirmed>=30][1])
date2 <- as.Date(date1 +7); date3 <- as.Date(date2+7); date4 <- as.Date(date3+7); date5 <- as.Date(date4+7); enddate <- as.Date(date5+7)
yb = -25; yt = -22
plotlines <- plotTS(df, mode="percent", title="Mexico", limits=NULL)+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = womenviolence, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = strike, colour = colpublicneg, linetype=2)
addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
#plot for paper
plotlines <- plotTS(df, mode="percent", title="Mexico", limits=c(-25,50))+
geom_vline(xintercept = as.numeric(lockdown), colour = collockdown, linetype=2)+
geom_vline(xintercept = womenviolence, colour = colpublicneg, linetype=2)+
geom_vline(xintercept = strike, colour = colpublicneg, linetype=2)+
theme(axis.title.y.left= element_blank(), legend.position="none")
plotmex <- addperiods(plotlines, controlstart, date1, date2, date3, date4, date5, enddate, yb, yt)
(df %>% group_by(wordlist) %>% summarize(meanpr = mean(pr), sdpr = sd(pr), meanbl = mean(bl), meancilow = mean(prlow), meancihigh = mean(prhigh)))
```
\newpage
# Combined country figures
## Example countries for Figure 1: Italy, Spain, US, Germany
```{r, Figure 1 example countries timeline, fig.width=12, fig.height=10, warning=FALSE, cache=TRUE}
cowplot::plot_grid(plotita, plotger, plotesp, plotusa, ncol=2,hjust=0, vjust =1)
ggsave('figures/Figure1_countriesR.pdf', width=12, height=10, dpi=300)
```
## Countries for Supplementary Fig S1: Other European countries
```{r, Figure S1 example countries timeline, fig.width=12, fig.height=20, warning=FALSE, cache=TRUE}
cowplot::plot_grid(plotaut, plotche, plotnet, plotbel, plotuk, plotire, plotfra, ncol=2,hjust=0, vjust =1)
ggsave('figures/FigureS1_countriesR.pdf', width=12, height=17, dpi=300)
```
## Countries for Supplementary Fig S2: Other non-European countries
```{r, Figure S2 example countries timeline, fig.width=12, fig.height=20, warning=FALSE, cache=TRUE}
cowplot::plot_grid(plotnzl, plotaus, plotcan, plotecu, plotper, plotmex, plotchl, ncol=2,hjust=0, vjust =1)
ggsave('figures/FigureS2_countriesR.pdf', width=12, height=17, dpi=300)
```
\newpage
# Country comparison: percentage change in 5 weeks since Covid-19 outbreak vs. the baseline (Figure 2 )
```{r, Subplots Figure 2 country comparison, fig.width=3.5, fig.height=4.5, warning=FALSE}
#load dataset with means since day with 30 cases
all <- read.csv("data_main/Outbreak-30-Levels.csv")
all <- all %>%
mutate(country = dplyr::recode(country, BelgiumDutch="Belgium", CanadaEnglish="Canada", NewZealand ="New Zealand"))
f <- all$wordlist=="anxiety"
seldf <- data.frame(country=all$country[f],
anx = 100*(all$pr[f]-all$bl[f])/all$bl[f],
anx_low = 100*(all$low[f]-all$bl[f])/all$bl[f],
anx_high = 100*(all$high[f]-all$bl[f])/all$bl[f])
f <- all$wordlist=="sadness"
seldf <- cbind(seldf, data.frame(sad = 100*(all$pr[f]-all$bl[f])/all$bl[f],
sad_low = 100*(all$low[f]-all$bl[f])/all$bl[f],
sad_high = 100*(all$high[f]-all$bl[f])/all$bl[f]))
f <- all$wordlist=="anger"
seldf <- cbind(seldf, data.frame(ang = 100*(all$pr[f]-all$bl[f])/all$bl[f],
ang_low = 100*(all$low[f]-all$bl[f])/all$bl[f],
ang_high = 100*(all$high[f]-all$bl[f])/all$bl[f]))