-
Notifications
You must be signed in to change notification settings - Fork 1
/
responsabilityLevel.R
87 lines (72 loc) · 2.92 KB
/
responsabilityLevel.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
# Packages ####
library(tidyverse)
source("functions.R", encoding = "UTF-8")
get_age_category <- function(ages){
groups <- seq(from = 13,
to = max(Data$ses_age, na.rm = T),
by = 5)
age_cats <- c()
for (i in 1:length(ages)){
if (!is.na(ages[i])){
age_cats[i] <- max(groups[groups<=ages[i]],
na.rm = T)
} else (age_cats[i] <- NA)
}
return(age_cats)
}
# Data ####
Data <- readRDS("_SharedFolder_quorum-enviro/data/cleanData/data.rds")
print("Citoyens")
table(Data$responsability_climateChangeCitizens)
print("Municipalités")
table(Data$responsability_climateChangeMuniGovt)
print("Gouv provincial")
table(Data$responsability_climateChangeProvGovt)
print("Gouv fédéral")
table(Data$responsability_climateChangeFedGovt)
print("Entreprises")
table(Data$responsability_climateChangeEnterprise)
print("OBNL")
table(Data$responsability_climateChangeOBNL)
names(Data %>% select(starts_with("radicalisation")))
Graph <- Data %>%
select(-responsability_climateChangeDiscuss) %>%
mutate(global_tolerance = minmaxNormalization(rowSums(select(., starts_with("radicalisation_tolerate"))))) %>%
pivot_longer(.,
cols = starts_with("responsability_climateChange"),
names_to = "actor", values_to = "responsability",
names_prefix = "responsability_climateChange") %>%
select(id, actor, responsability, global_tolerance) %>%
group_by(actor, responsability) %>%
summarise(n = n(),
tolerance = mean(global_tolerance)) %>%
mutate(responsability = case_when(
responsability == 0 ~ "Pas du tout\nresponsable",
responsability == 0.33 ~ "Un peu\nresponsable",
responsability == 0.67 ~ "Partiellement\nresponsable",
responsability == 1 ~ "Pleinement\nresponsable"
))
ggplot(Graph, aes(x = factor(responsability,
levels = c("Pas du tout\nresponsable",
"Un peu\nresponsable",
"Partiellement\nresponsable",
"Pleinement\nresponsable")),
y = tolerance)) +
geom_bar(stat = "identity",
aes(alpha = n)) +
geom_text(angle = 90,
aes(y = tolerance - 0.1, label = paste0(n, " répondants")),
size = 3.5, vjust = 2.25) +
#geom_text() +
xlab("") +
ylab("Tolérance globale") +
facet_wrap(~actor) +
clessnverse::theme_clean_light() +
theme(axis.text.x = element_text(size = 7))
#axis.line.x = element_blank(),
#axis.ticks.x = element_blank(),
#strip.background.x = element_blank())
ggsave("_SharedFolder_quorum-enviro/_papier-radicalisation-enviro/graphs/respo_tolerance2.png",
width = 8, height = 6)
#### Testing logistic regs on vege and
## Qui sont ceux qui tolèrent les actions violentes?? ####