-
Notifications
You must be signed in to change notification settings - Fork 1
/
apsa.R
614 lines (530 loc) · 29.8 KB
/
apsa.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
library(tidyverse)
Data <- haven::read_sav("_SharedFolder_quorum-enviro/data/ULA011-données.Sav")
## Codebook ####
#var_name <- c()
#q_label <- c()
#answers_labels <- c()
#answers_codes <- c()
#for (i in 1:length(names(Data))){
# #i <- 15
# col <- names(Data)[i]
# var_name[i] <- col
# q_label[i] <- attributes(Data[[col]])$label
# answers_labels[i] <- paste0(names(attributes(Data[[col]])$labels), collapse = ", ")
# answers_codes[i] <- paste0(attributes(Data[[col]])$labels, collapse = ", ")
#}
#
#codebook <- as.data.frame(cbind(var_name, q_label, answers_labels, answers_codes))
#
#writexl::write_xlsx(codebook, "_SharedFolder_quorum-enviro/codebook.xlsx")
# Q57_A1, Q57_A2, Q57_A3, Q60, Q61, Q55_A1, Q55_A2
Graph <- Data %>%
select(c(Q55_A1, Q55_A2, Q57_A1, Q57_A2, Q57_A3, Q60, Q61)) %>%
pivot_longer(., everything())
ggplot(Graph, aes(x = value, y = name)) +
ggridges::geom_density_ridges()
Graph <- Data %>%
select(c(Q55_A1, Q57_A1, Q57_A2, Q57_A3)) %>%
pivot_longer(., everything()) %>%
mutate(value2 = ifelse(value > 3, 4, value),
value2 = ifelse(value < 3, 2, value2)) %>%
filter(value2 == 2)
ggplot(Graph, aes(x = value2, y = name)) +
geom_histogram() +
facet_wrap(~name) +
ggridges::stat_binline(scale = 0.9, ) +
scale_x_discrete(breaks = c(2,3,4))
ggplot(Graph, aes(x = value2)) +
geom_bar() +
facet_wrap(~name, ncol = 1)
ggsave("_SharedFolder_quorum-enviro/test.png",
width = 5, height = 10)
ggplot(Graph, aes(x = name)) +
geom_bar()# +
facet_wrap(~value2, ncol = 1)
ggsave("_SharedFolder_quorum-enviro/test.png",
width = 5, height = 10)
Graph <- Data %>%
select(c(Q55_A1, Q57_A1, Q57_A2, Q57_A3)) %>%
pivot_longer(., everything()) %>%
mutate(value2 = ifelse(value > 3, 4, value),
value2 = ifelse(value < 3, 2, value2)) %>%
group_by(name, value2) %>%
summarise(n = n()) %>%
mutate(n_group = sum(n),
prop = n/n_group*100) %>%
filter(value2 == 2)
ggplot(Graph, aes(x = reorder(name, -prop), y = prop)) +
geom_bar(stat = "identity", color = "#2E8B57",
fill = "#2E8B57", alpha = 0.7) +
scale_x_discrete(#breaks = c("Q55_A1", "Q57_A1", "Q57_A3", "Q57_A2"),
labels = c("Comme le fait le système\nactuellement en vigueur au Canada", "Fonds redistribués à\nla population",
"Fonds utilisés pour soutenir\ntravailleurs des\ncombustibles fossiles", "Fonds utilisés pour\ncréer des emplois dans le\ndomaine des énergies vertes")) +
ggthemes::theme_clean() +
labs(title = "\nProportion des répondants en désaccord avec la\nquestion suivante en fonction de l'utilisation des fonds",
subtitle = "\nÊtes-vous en faveur ou en défaveur que l'on continue d'augmenter\nle prix des émissions de gaz à effet de serre?\n") +
xlab("") +
ylab("\nProportion (%)\n") +
geom_text(aes(y = prop + 0.5, label = round(prop)))
ggsave("_SharedFolder_quorum-enviro/test.png",
width = 8, height = 10)
source("functions.R", encoding = "UTF-8")
topdown_fa(Graph)
## 1. Descriptif univarié ####
univar_plot <- function(question, title){
#question <- "Q55_A1"
GraphData <- Data %>%
group_by(.data[[question]]) %>%
summarise(n = n()) %>%
mutate(n_total = sum(n),
prop = n/n_total*100)
graph <- ggplot(GraphData, aes(x = .data[[question]], y = prop)) +
geom_bar(width = 0.97, stat = "identity", color = "#2E8B57",
fill = "#2E8B57", alpha = 0.7) +
geom_text(aes(y = prop+3, label = round(prop)), color = "#4B4544") +
ggtitle(title) +
theme_minimal() +
scale_y_continuous(limits = c(0,100))+
scale_x_continuous(labels = c("Strongly\nin disfavor", "Somewhat\nin disfavor", "Neutral",
"Somewhat\nin favor", "Strongly\nin favor"),
breaks = 1:5) +
labs(caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in favor' or 'somewhat in favor' have been combined into a single group referred to as 'in favor'.")) +
xlab("") +
ylab("\nProportion of\nthe survey sample (%)\n") +
theme(plot.background = element_rect(fill = "white"))
return(graph)
}
#attach(Data)
univar_plot("Q55_A1", "\nAre you in favor of continuing to increase the price\nof carbon dioxide emissions (like the existing system in Canada)?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb2_base.png")
univar_plot("Q55_A2", "\nAre you in favor of progressively decreasing\nfossil fuels production in Canada?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossils_base.png")
univar_plot("Q57_A1", "\nWould you be in favor of continuing to increase the price on carbon dioxide emissions\nif the funds would be distributed back to the population [...]?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb2_topop.png")
univar_plot("Q57_A2", "\nWould you be in favor of continuing to increase the price on carbon dioxide emissions\nif the funds would be used to create jobs in green energy [...]?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb2_green.png")
univar_plot("Q57_A3", "\nWould you be in favor of continuing to increase the price on carbon dioxide emissions\nif the funds would be used to support fossil fuels workers?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb2_fossil.png")
univar_plot("Q60", "\nWould you be in favor of progressively decreasing fossil fuels production in Canada\nif more jobs were created in green energy than lost in the process?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossils_green.png")
univar_plot("Q61", "\nWould you be in favor of progressively decreasing fossil fuels production in Canada\nif fossil fuel workers were to be ensured support in the transition [...]?\n")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossils_fossils.png")
## 2. Descriptif multivarié ####
# Carbon dioxide ####
provinces <- names(attributes(Data$PROV)$labels)
names(provinces) <- as.character(attributes(Data$PROV)$labels)
provinces[provinces == "Colombie-Britannique"] <- "British Columbia"
provinces[provinces == "Québec"] <- "Quebec"
BaseGraph <- Data %>%
mutate(id = 1:nrow(.)) %>%
select(id, PROV, Q55_A1, Q57_A1, Q57_A2, Q57_A3) %>%
pivot_longer(., cols = c(Q55_A1, starts_with("Q57"))) %>%
mutate(prov_join = case_when(
PROV == 9 ~ "Ontario",
PROV == 11 ~ "Quebec",
PROV %in% c(1,12) ~ "Alberta and Saskatchewan",
PROV == 2 ~ "British Columbia"),
PROV = provinces[as.character(PROV)],
position = case_when(
value %in% 1:2 ~ "In disfavor",
value %in% 4:5 ~ "In favor",
value == 3 ~ "Neutral"
),
salience = case_when(
value %in% c(1,5) ~ "Strongly",
value %in% c(2,4) ~ "Somewhat"
),
salience = factor(salience, levels = c("Strongly", "Somewhat")),
name = case_when(
name == "Q55_A1" ~ "Like the existing\nsystem in Canada",
name == "Q57_A1" ~ "Funds distributed\nback to the population",
name == "Q57_A2" ~ "Funds used to create\njobs in green energy",
name == "Q57_A3" ~ "Funds used to support\nfossil fuels workers"
))
# carb_favor
Graph1 <- BaseGraph %>%
group_by(name, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100)
Graph1 %>%
filter(position == "In favor") %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
ylab("<br>Proportion of the<br>sample in favor (%)<br>") +
labs(title = "<br>Proportion of the sample in favor with the following question<br>depending on how the funds are used",
subtitle = "<br>Are you in favor of continuing to increase the price of carbon dioxide emissions?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in favor' or 'somewhat in favor' have been combined into a single group referred to as 'in favor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top") +
geom_text(aes(y = prop_position+4, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_favor.png",
width = 9, height = 6)
# carb_favor province
carb_favor_province <- BaseGraph %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100)
carb_favor_province %>%
filter(position == "In favor") %>%
mutate(prov_join = factor(prov_join, levels = c("British Columbia", "Ontario", "Quebec", "Alberta and Saskatchewan")),
facet_label = paste0(prov_join, "\nn = ", n_question)) %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("<br>Proportion of the<br>sample in favor (%)<br>") +
labs(title = "<br>Proportion of the sample in favor with the following question<br>depending on how the funds are used",
subtitle = "<br>Are you in favor of continuing to increase the price of carbon dioxide emissions?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in favor' or 'somewhat in favor' have been combined into a single group referred to as 'in favor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_favor_provinces.png",
width = 9, height = 6)
# carb favor province join
carb_favor_province_join <- BaseGraph %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100,
facet_label = paste0(prov_join, "\nn = ", n_question))
carb_favor_province_join %>%
filter(position == "In favor") %>%
#mutate(PROV = factor(PROV, levels = c("British Columbia", "Ontario", "Quebec", "Alberta", "Saskatchewan"))) %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("\nProportion of the\nsample in favor (%)\n") +
labs(title = "\nProportion of the sample in favor with the following question\ndepending on how the funds are used",
subtitle = "\nAre you in favor of continuing to increase the price of carbon dioxide emissions?\n",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_favor_prov_join.png",
width = 9, height = 6)
# carb_disfavor
Graph1 %>%
filter(position == "In disfavor") %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
theme_minimal() +
xlab("") +
ylab("<br>Proportion of the<br>sample in disfavor (%)<br>") +
labs(title = "<br>Proportion of the sample in disfavor with the following question<br>depending on how the funds are used",
subtitle = "<br>Are you in favor of continuing to increase the price of carbon dioxide emissions?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in disfavor' or 'somewhat in disfavor' have been combined into a single group referred to as 'in disfavor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top") +
geom_text(aes(y = prop_position+4, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_disfavor.png",
width = 9, height = 6)
# carb_disfavor province
carb_favor_province %>%
filter(position == "In disfavor") %>%
mutate(PROV = factor(PROV, levels = c("British Columbia", "Ontario", "Quebec", "Alberta", "Saskatchewan"))) %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("\nProportion of the\nsample in disfavor (%)\n") +
labs(title = "\nProportion of the sample in disfavor with the following question\ndepending on how the funds are used",
subtitle = "\nAre you in favor of continuing to increase the price of carbon dioxide emissions?\n",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_disfavor_provinces.png",
width = 9, height = 6)
# carb_disfavor province join
carb_favor_province_join %>%
filter(position == "In disfavor") %>%
#mutate(PROV = factor(PROV, levels = c("British Columbia", "Ontario", "Quebec", "Alberta", "Saskatchewan"))) %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("<br>Proportion of the<br>sample in disfavor (%)<br>") +
labs(title = "<br>Proportion of the sample in disfavor with the following question<br>depending on how the funds are used",
subtitle = "<br>Are you in favor of continuing to increase the price of carbon dioxide emissions?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in disfavor' or 'somewhat in disfavor' have been combined into a single group referred to as 'in disfavor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/carb_disfavor_prov_join.png",
width = 9, height = 6)
# Decreasing fossil fuels ####
BaseGraph2 <- Data %>%
mutate(id = 1:nrow(.)) %>%
select(id, PROV, Q55_A2, Q60, Q61) %>%
pivot_longer(., cols = c(Q55_A2, Q60, Q61)) %>%
mutate(prov_join = case_when(
PROV == 9 ~ "Ontario",
PROV == 11 ~ "Quebec",
PROV %in% c(1,12) ~ "Alberta and Saskatchewan",
PROV == 2 ~ "British Columbia"),
PROV = provinces[as.character(PROV)],
position = case_when(
value %in% 1:2 ~ "In disfavor",
value %in% 4:5 ~ "In favor",
value == 3 ~ "Neutral"
),
salience = case_when(
value %in% c(1,5) ~ "Strongly",
value %in% c(2,4) ~ "Somewhat"
),
salience = factor(salience, levels = c("Strongly", "Somewhat")),
name = case_when(
name == "Q55_A2" ~ "No consequence\nspecified",
name == "Q60" ~ "More support for\nfossil fuel workers",
name == "Q61" ~ "More jobs created in\ngreen energy"
))
Graph2 <- BaseGraph2 %>%
group_by(name, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100)
# fossil favor
Graph2 %>%
filter(position == "In favor") %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
ylab("<br>Proportion of the<br>sample in favor (%)<br>") +
labs(title = "<br>Proportion of the sample in favor with the following question<br>depending on the consequence on the economy",
subtitle = "<br>Are you in favor of progressively decreasing fossil fuels production in Canada?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in favor' or 'somewhat in favor' have been combined into a single group referred to as 'in favor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top") +
geom_text(aes(y = prop_position+4, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_favor.png",
width = 9, height = 6)
Graph2 %>%
filter(position == "In disfavor") %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
theme_minimal() +
xlab("") +
ylab("<br>Proportion of the<br>sample in disfavor (%)<br>") +
labs(title = "<br>Proportion of the sample in disfavor with the following question<br>depending on the consequence on the economy",
subtitle = "<br>Are you in favor of progressively decreasing fossil fuels production in Canada?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in disfavor' or 'somewhat in disfavor' have been combined into a single group referred to as 'in disfavor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top") +
geom_text(aes(y = prop_position+4, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_disfavor.png",
width = 9, height = 6)
# fossil favor provinces
fossil_favor_province <- BaseGraph2 %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100)
fossil_favor_province %>%
filter(position == "In favor") %>%
mutate(prov_join = factor(prov_join, levels = c("British Columbia", "Ontario", "Quebec", "Alberta and Saskatchewan")),
facet_label = paste0(prov_join, "\nn = ", n_question)) %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("<br>Proportion of the<br>sample in favor (%)<br>") +
labs(title = "<br>Proportion of the sample in favor with the following question<br>depending on the consequence on the economy",
subtitle = "<br>Are you in favor of progressively decreasing fossil fuels production in Canada?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in favor' or 'somewhat in favor' have been combined into a single group referred to as 'in favor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+9, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_favor_provinces.png",
width = 9, height = 6)
# fossil favor provinces join
fossil_favor_province_join <- BaseGraph2 %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100,
facet_label = paste0(prov_join, "\nn = ", n_question))
fossil_favor_province_join %>%
filter(position == "In favor") %>%
#mutate(PROV = factor(PROV, levels = c("British Columbia", "Ontario", "Quebec", "Alberta", "Saskatchewan"))) %>%
ggplot(aes(x = reorder(name, prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#2E8B57", fill = "#2E8B57") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("\nProportion of the\nsample in favor (%)\n") +
labs(title = "\nProportion of the sample in favor with the following question\ndepending on the consequence on the economy",
subtitle = "\nAre you in favor of progressively decreasing fossil fuels production in Canada?\n",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 6.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_favor_prov_join.png",
width = 9, height = 6)
# fossil disfavor provinces
fossil_disfavor_province <- BaseGraph2 %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100)
fossil_disfavor_province %>%
filter(position == "In disfavor") %>%
mutate(prov_join = factor(prov_join, levels = c("British Columbia", "Ontario", "Quebec", "Alberta and Saskatchewan")),
facet_label = paste0(prov_join, "\nn = ", n_question)) %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("<br>Proportion of the<br>sample in disfavor (%)<br>") +
labs(title = "<br>Proportion of the sample in disfavor with the following question<br>depending on the consequence on the economy",
subtitle = "<br>Are you in favor of progressively decreasing fossil fuels production in Canada?<br>",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.\nRespondents who indicated they were either 'strongly in disfavor' or 'somewhat in disfavor' have been combined into a single group referred to as 'in disfavor'.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 5.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+9, label = round(prop_position)), color = "#4B4544") +
theme(axis.title.y = ggtext::element_markdown(),
plot.title = ggtext::element_markdown(),
plot.subtitle = ggtext::element_markdown())
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_disfavor_provinces.png",
width = 9, height = 6)
# fossil disfavor provinces join
fossil_disfavor_province_join <- BaseGraph2 %>%
filter(!(is.na(prov_join))) %>%
group_by(name, prov_join, position, salience) %>%
summarise(n_group = n()) %>%
group_by(name, prov_join, position) %>%
mutate(n_position = sum(n_group)) %>%
group_by(name, prov_join) %>%
mutate(n_question = sum(n_group),
prop_group = n_group/n_question*100,
prop_position = n_position/n_question*100,
facet_label = paste0(prov_join, "\nn = ", n_question))
fossil_disfavor_province_join %>%
filter(position == "In disfavor") %>%
#mutate(PROV = factor(PROV, levels = c("British Columbia", "Ontario", "Quebec", "Alberta", "Saskatchewan"))) %>%
ggplot(aes(x = reorder(name, -prop_position), y = prop_group)) +
geom_bar(stat = "identity", aes(alpha = salience),
color = "#D4342E", fill = "#D4342E") +
theme_minimal() +
xlab("") +
facet_wrap(~facet_label)+
ylab("\nProportion of the\nsample in disfavor (%)\n") +
labs(title = "\nProportion of the sample in disfavor with the following question\ndepending on the consequence on the economy",
subtitle = "\nAre you in favor of progressively decreasing fossil fuels production in Canada?\n",
caption = paste0("n = ", nrow(Data), ". Data collected from a survey conducted on August 2022 across Canada for all ages by the firm Synopsis.")) +
scale_y_continuous(limits = c(0,100)) +
scale_alpha_manual("", values = c("Somewhat" = 0.3, "Strongly" = 0.7)) +
theme(plot.background = element_rect(fill = "white"),
legend.position = "top",
axis.text.x = element_text(size = 6.5, angle = 45, vjust = 0.65)) +
geom_text(aes(y = prop_position+8, label = round(prop_position)), color = "#4B4544")
ggsave("_SharedFolder_quorum-enviro/apsa_sept10/fossil_disfavor_provinces_join.png",
width = 9, height = 6)