knitr::opts_chunk$set(message = FALSE)
library(haven)
library(ggplot2)
library(reshape2)
library(ggthemes)
library(dplyr)
library(qualtRics)
library(tidyr)
library(stringr)
library(gridExtra)
library(scales)
library(gtsummary)
#read data with qualtRics 
data <- read_spss("survey_5.3.2023.sav")

#create a new dataset with combined variables for men and women
new_data <- data[, 1:19]


#combine variables for men and women
new_data$Q2 <- coalesce(data$Q2_cs_filter, data$Q2_f)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1

#Q4 - influence past
new_data$Q4_1 <- coalesce(data$Q4_influence_past_1, data$Q4_f_influence_past_1)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q4_2 <- coalesce(data$Q4_influence_past_2, data$Q4_f_influence_past_2)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q4_3 <-coalesce(data$Q4_influence_past_3, data$Q4_f_influence_past_3)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7

#Q5 - influence future
new_data$Q5 <- coalesce(data$Q5_influence_future, data$Q5_f_influence_futur)

#Q6 - influence comments
new_data$Q6 <- coalesce(data$Q6_influence_comment, data$Q6_f_influence_comme)

#Q10 - meritocracy - past
new_data$Q10_1 <- coalesce(data$Q10_meritocracy_past_1, data$Q10_f_meritocracy_pa_1)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q10_2 <- coalesce(data$Q10_meritocracy_past_2, data$Q10_f_meritocracy_pa_2)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q10_3 <- coalesce(data$Q10_meritocracy_past_3, data$Q10_f_meritocracy_pa_3)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7

#Q11 - meritocracy - future
new_data$Q11 <- coalesce(data$Q11_meritocracy_futu, data$Q11_f_meritocracy_fu)

#Q12 - meritocracy - comments
new_data$Q12 <- coalesce(data$Q12_meritocracy_comm, data$Q12_f_meritocracy_co)

#Q13 - functioning - past
new_data$Q13 <- coalesce(data$Q13_functioning_poli,data$Q13_f_functioning_po)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, and 5

#Q14 - functioning - hr
new_data$Q14 <- coalesce(data$Q14_functioning_hr, data$Q14_f_functioni_hr)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, and 5

#Q15 - democratic decline - future expectations
new_data$Q15 <- coalesce(data$Q15_democracy_future, data$Q15_f_democracy_futu)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, and 999

#Q16 - democratic decline - protest
new_data$Q16_1 <- coalesce(data$Q16_democracy_1, data$Q16_f_democracy_1)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q16_2 <- coalesce(data$Q16_democracy_2, data$Q16_f_democracy_2)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q16_3 <- coalesce(data$Q16_democracy_3, data$Q16_f_democracy_3)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q16_4 <- coalesce(data$Q16_democracy_4, data$Q16_f_democracy_4)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q16_5 <- coalesce(data$Q16_democracy_5, data$Q16_f_democracy_5)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7

#Q17 - democratic decline - comments
new_data$Q17 <- coalesce(data$Q17_democracy_commen, data$Q17_f_democracy_comm) 

#Q19 - investment at work - past
new_data$Q19 <- coalesce(data$Q19_investment_past, data$Q19_f_investment_pa) 

#Q20 - investment at work - collegaues
new_data$Q20 <- coalesce(data$Q20_investment_compa, data$Q20_f_investment_com) 

#Q21 - investment at work - future
new_data$Q21 <- coalesce(data$Q21_investment_futur, data$Q21_f_investment_fut)

#Q21_a - investment at work - comments
new_data$Q21_a <- coalesce(data$Q21_comment, data$Q21_f_comment)

#Q22 - voice - past
new_data$Q22_1 <- coalesce(data$Q22_voice_past_1, data$Q22_f_voice_past_1)
new_data$Q22_2 <- coalesce(data$Q22_voice_past_2, data$Q22_f_voice_past_2)
new_data$Q22_3 <- coalesce(data$Q22_voice_past_3, data$Q22_f_voice_past_3)

#Q22_a - voice - collegaues
new_data$Q22_a <- coalesce(data$Q22a_voice_compare, data$Q22a_f_voice_compare)

#Q23 - voice - future
new_data$Q23 <- coalesce(data$Q23_voice_future, data$Q23_f_voice_future)

#Q24 - voice - comments
new_data$Q24 <- coalesce(data$Q24_voice_comment, data$Q24_f_voice_comment)

#Q25 - exit 
new_data$Q25 <- coalesce(data$Q25_CS_resign, data$Q25_f_CS_resign)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, and 5

#Q26 - exit - private sector's equal salary
new_data$Q26 <- coalesce(data$Q26_CS_resign_money, data$Q26_f_CS_resign_mone)

#Q27-  reutrn to CS
new_data$Q27 <- coalesce(data$Q27_CS_return_money, data$Q27_f_CS_return_mon)

#Q27_a- comments
new_data$Q27_a <- coalesce(data$Q27_comment, data$Q27_f_comment)

#Q28 - PSM
new_data$Q28_1 <- coalesce(data$Q28_PSM_1, data$Q28_f_PSM_1)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q28_2 <- coalesce(data$Q28_PSM_2, data$Q28_f_PSM_2)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q28_3 <- coalesce(data$Q28_PSM_3, data$Q28_f_PSM_3)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7
new_data$Q28_4 <- coalesce(data$Q28_PSM_4, data$Q28_f_PSM_4)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7

#Q29 - subotage
new_data$Q29_1 <- coalesce(data$Q29_subotage_1, data$Q29_f_subotage_1)
new_data$Q29_2 <- coalesce(data$Q29_subotage_2, data$Q29_f_subotage_2)
new_data$Q29_3 <- coalesce(data$Q29_subotage_3, data$Q29_f_subotage_3)
new_data$Q29_4 <- coalesce(data$Q29_subotage_4, data$Q29_f_subotage_4)
new_data$Q29_5 <- coalesce(data$Q29_subotage_5, data$Q29_f_subotage_5)
new_data$Q29_6 <- coalesce(data$Q29_subotage_6, data$Q29_f_subotage_6)
new_data$Q29_7 <- coalesce(data$Q29_subotage_7, data$Q29_f_subotage_7)
new_data$Q29_8 <- coalesce(data$Q29_subotage_8, data$Q29_f_subotage_8)
new_data$Q29_9 <- coalesce(data$Q29_subotage_9, data$Q29_f_subotage_9)

#Q29_a - subotage comments
new_data$Q29_a <- coalesce(data$Q29a_subotage_commen, data$Q29a_f_subotage_comm)

#Q31 - unit (if still works)
new_data$Q31 <- coalesce(data$Q31_unit, data$Q31_f_unit)

#Q31_a - unit (if still works) - other
new_data$Q31_a <- coalesce(data$Q31_unit_26_TEXT, data$Q31_f_unit_26_TEXT)

#Q32 - unit (if left)
new_data$Q32 <- coalesce(data$Q32_unit_left, data$Q32_f_unit_left)

#Q32_a - unit (if left) - other
new_data$Q32_a <- coalesce(data$Q32_unit_left_26_TEXT, data$Q32_unit_left_26_TEXT)

#Q33 - seniority (if still works)
new_data$Q33 <- coalesce(data$Q33_seniority, data$Q33_f_seniority)

#Q34 - seniority (if left)
new_data$Q34 <- coalesce(data$Q34_seniority_left, data$Q34_f_seniority_left)

#Q35 - appointing (if still works)
new_data$Q35 <- coalesce(data$Q35_appointing, data$Q35_f_appointing) 

#Q35_a - appointing (if still works) - other
new_data$Q35_a <- coalesce(data$Q35_appointing_4_TEXT, data$Q35_f_appointing_4_TEXT) 

#Q36 - appointing (if left)
new_data$Q36 <- coalesce(data$Q36_appointing_left, data$Q36_f_appointing_lef) 

#Q36_a - appointing (if left) - other
new_data$Q36_a <- coalesce(data$Q36_appointing_left_4_TEXT, data$Q36_f_appointing_lef_4_TEXT) 

#Q37 - percieved seniority (if still works)
new_data$Q37 <- coalesce(data$Q37_senior_per, data$Q37_f_senior_per) 

#Q38 - percieved seniority (if left)
new_data$Q38 <- coalesce(data$Q38_senior_per_left, data$Q38_f_senior_per_le) 

#Q39 - jewish
new_data$Q39 <- coalesce(data$Q39_jewish, data$Q39_f_jewish) 
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 0 and 1

#Q40 - age
new_data$Q40 <- coalesce(data$Q40_age, data$Q40_f_age) 

#Q41 - religion
new_data$Q41 <- coalesce(data$Q41_religion, data$Q41_f_religion) 
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 0, 1, 2, 3, and 4

#Q42 - education
new_data$Q42 <- coalesce(data$Q42_education, data$Q42_f_education)

#Q42_a - education - other
new_data$Q42_a <- coalesce(data$Q42_education_999_TEXT, data$Q42_f_education_999_TEXT)

#Q43 - education field
new_data$Q43 <- coalesce(data$Q43_education_field, data$Q43_f_education_fiel)

#Q44 - survey feelings
new_data$Q44 <- coalesce(data$Q44_feelings, data$Q44_f_feelings)

#Q45 - survey formulation
new_data$Q45 <- coalesce(data$Q45_common_method_va, data$Q45_f_common_meth_va)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 1, 2, 3, 4, 5, 6, and 7

Perceptions of Influence (Past)

Q4_1 <- as.data.frame(
  new_data %>%
    group_by(Q4_1) %>%
    filter(!is.na(Q4_1))  %>%
    summarize(N = n()))

Q4_2 <- as.data.frame(
  new_data %>%
    group_by(Q4_2) %>%
    filter(!is.na(Q4_2))  %>%
    summarize(N = n()))

Q4_3 <- as.data.frame(
  new_data %>%
    group_by(Q4_3) %>%
    filter(!is.na(Q4_3))  %>%
    summarize(N = n()))


Q4_1_merged <- 
  Q4_1 %>%
  mutate(Q4_1 = case_when(Q4_1 %in% c("1","2", "3") ~ "1",
                        Q4_1 %in% "4" ~ "2",
                        Q4_1 %in% c("5","6", "7") ~ "3"))

Q4_2_merged <- 
  Q4_2 %>%
  mutate(Q4_2 = case_when(Q4_2 %in% c("1","2", "3") ~ "1",
                        Q4_2 %in% "4" ~ "2",
                        Q4_2 %in% c("5","6", "7") ~ "3"))

Q4_3_merged <- 
  Q4_3 %>%
  mutate(Q4_3 = case_when(Q4_3 %in% c("1","2", "3") ~ "1",
                        Q4_3 %in% "4" ~ "2",
                        Q4_3 %in% c("5","6", "7") ~ "3"))

Q4_1_new <- Q4_1_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q4_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_2_new <- Q4_2_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q4_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_3_new <- Q4_3_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q4_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q_4_1_p <- ggplot(Q4_1_new) +
  geom_bar(aes(factor(x=Q4_1), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q4_1), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(breaks = c(0, 0.25, 0.5, 0.75, 1),
                     labels = scales::percent,
                     limits = c(0, 1)) +
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("לדרג המקצועי ביחידה שבה אני עובד הייתה השפעה על המדיניות שקודמה בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_2_p <-ggplot(Q4_2_new) +
  geom_bar(aes(factor(x=Q4_2), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q4_2), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה מעצמאות בקידום מדיניות בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_3_p <-ggplot(Q4_3_new) +
  geom_bar(aes(factor(x=Q4_3), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q4_3), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה משיקול דעת רחב ביישום מדיניות בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_4_1_p, Q_4_2_p, Q_4_3_p, ncol = 1)

Perceptions of Influence (Past) by Seniority

Q4_1_37 <- as.data.frame(
  new_data %>%
    group_by(Q4_1, Q37) %>%
    filter(!is.na(Q4_1),!is.na(Q37))  %>%
    summarize(N = n()))

Q4_2_37 <- as.data.frame(
  new_data %>%
    group_by(Q4_2, Q37) %>%
    filter(!is.na(Q4_2),!is.na(Q37))  %>%
    summarize(N = n()))

Q4_3_37 <- as.data.frame(
  new_data %>%
    group_by(Q4_3, Q37) %>%
    filter(!is.na(Q4_3),!is.na(Q37))  %>%
    summarize(N = n()))
  
Q4_1_37_merged <- 
  Q4_1_37 %>%
  mutate(Q4_1 = case_when(Q4_1 %in% c("1","2", "3") ~ "1",
                        Q4_1 %in% "4" ~ "2",
                        Q4_1 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q4_2_37_merged <- 
  Q4_2_37 %>%
  mutate(Q4_2 = case_when(Q4_2 %in% c("1","2", "3") ~ "1",
                        Q4_2 %in% "4" ~ "2",
                        Q4_2 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q4_3_37_merged <- 
  Q4_3_37 %>%
  mutate(Q4_3 = case_when(Q4_3 %in% c("1","2", "3") ~ "1",
                        Q4_3 %in% "4" ~ "2",
                        Q4_3 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q4_1_37_merged_new <- Q4_1_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q4_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_2_37_merged_new <- Q4_2_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q4_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_3_37_merged_new <- Q4_3_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q4_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))


labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)

Q_4_1_p <- ggplot(Q4_1_37_merged_new) +
  geom_bar(aes(x=factor(Q4_1), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_1), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("לדרג המקצועי ביחידה שבה אני עובד הייתה השפעה על המדיניות שקודמה בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_2_p <- ggplot(Q4_2_37_merged_new) +
  geom_bar(aes(x=factor(Q4_2), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_2), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה מעצמאות בקידום מדיניות בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_3_p <- ggplot(Q4_3_37_merged_new) +
  geom_bar(aes(x=factor(Q4_3), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_3), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה משיקול דעת רחב ביישום מדיניות בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`
  

grid.arrange(Q_4_1_p, Q_4_2_p, Q_4_3_p, ncol = 1)

Perceptions of Influence (Past) by Religion

Q4_1_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q4_1, Q41) %>%
    filter(!is.na(Q4_1),!is.na(Q41))  %>%
    summarize(N = n()))

Q4_2_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q4_2, Q41) %>%
    filter(!is.na(Q4_2),!is.na(Q41))  %>%
    summarize(N = n()))

Q4_3_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q4_3, Q41) %>%
    filter(!is.na(Q4_3),!is.na(Q41))  %>%
    summarize(N = n()))
  
Q4_1_41_merged <- 
  Q4_1_41 %>%
  mutate(Q4_1 = case_when(Q4_1 %in% c("1","2", "3") ~ "1",
                        Q4_1 %in% "4" ~ "2",
                        Q4_1 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q4_2_41_merged <- 
  Q4_2_41 %>%
  mutate(Q4_2 = case_when(Q4_2 %in% c("1","2", "3") ~ "1",
                        Q4_2 %in% "4" ~ "2",
                        Q4_2 %in% c("5","6", "7") ~ "3"),
        Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q4_3_41_merged <- 
  Q4_3_41 %>%
  mutate(Q4_3 = case_when(Q4_3 %in% c("1","2", "3") ~ "1",
                        Q4_3 %in% "4" ~ "2",
                        Q4_3 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q4_1_41_merged_new <- Q4_1_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q4_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_2_41_merged_new <- Q4_2_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q4_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q4_3_41_merged_new <- Q4_3_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q4_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  

Q_4_1_p <- ggplot(Q4_1_41_merged_new) +
  geom_bar(aes(x=factor(Q4_1), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_1), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("לדרג המקצועי ביחידה שבה אני עובד הייתה השפעה על המדיניות שקודמה בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_2_p <- ggplot(Q4_2_41_merged_new) +
  geom_bar(aes(x=factor(Q4_2), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_2), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה מעצמאות בקידום מדיניות בתחום הפעילות שלנו")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_4_3_p <- ggplot(Q4_3_41_merged_new) +
  geom_bar(aes(x=factor(Q4_3), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q4_3), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("הדרג המקצועי ביחידה שבה אני עובד נהנה משיקול דעת רחב ביישום מדיניות בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_4_1_p, Q_4_2_p, Q_4_3_p, ncol = 1)

Perceptions of Influence (Future)

Q5 <- as.data.frame(
  new_data %>%
    group_by(Q5) %>%
    filter(!is.na(Q5))%>%
    summarize(N = n()))

Q5_merged <- 
  Q5 %>%
  mutate(Q5 = case_when(Q5 %in% c("1","2") ~ "1",
                        Q5 %in% "3" ~ "2",
                        Q5 %in% c("4","5") ~ "3"))

Q5_new <- Q5_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q5) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))


ggplot(Q5_new) +
  geom_bar(aes(x=factor(Q5), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q5), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("החלשות והחלשות משמעותית", "ללא שינוי" ,"התחזקות והתחזקות משמעותית"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(
        text = element_text(family="Optima"),
        strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שתהיה התחזקות או החלשות \n ?במידת ההשפעה של הדרג המקצועי ביחידה שלך על מדיניות המשרד בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

Perceptions of Influence (Future) by Seniority

Q5_37 <- as.data.frame(
  new_data %>%
    group_by(Q5, Q37) %>%
    filter(!is.na(Q5),!is.na(Q37))  %>%
    summarize(N = n()))

  
Q5_37_merged <- 
  Q5_37 %>%
  mutate(Q5 = case_when(Q5 %in% c("1","2") ~ "1",
                        Q5 %in% "3" ~ "2",
                        Q5 %in% c("4","5") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q5_37_merged_new <- Q5_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q5) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)

ggplot(Q5_37_merged_new) +
  geom_bar(aes(x=factor(Q5), y=freq), stat="identity", position=position_dodge())+
  geom_text(aes(x=factor(Q5), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("החלשות והחלשות משמעותית", "ללא שינוי" ,"התחזקות והתחזקות משמעותית"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שתהיה התחזקות או החלשות \n ?במידת ההשפעה של הדרג המקצועי ביחידה שלך על מדיניות המשרד בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Influence (Future) by Religion

Q5_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q5, Q41) %>%
    filter(!is.na(Q5),!is.na(Q41))%>%
    summarize(N = n()))

Q5_41_merged <- 
  Q5_41 %>%
  mutate(Q5 = case_when(Q5 %in% c("1","2") ~ "1",
                        Q5 %in% "3" ~ "2",
                        Q5 %in% c("4","5") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q5_41_merged_new <- Q5_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q5) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  
ggplot(Q5_41_merged_new) +
  geom_bar(aes(x=factor(Q5), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q5), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("החלשות והחלשות משמעותית", "ללא שינוי" ,"התחזקות והתחזקות משמעותית"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
   theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שתהיה התחזקות או החלשות \n ?במידת ההשפעה של הדרג המקצועי ביחידה שלך על מדיניות המשרד בתחום הפעילות של היחידה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Meritiocracy (Past)

Q10_1 <- as.data.frame(
  new_data %>%
    group_by(Q10_1) %>%
    filter(!is.na(Q10_1))  %>%
    summarize(N = n()))

Q10_2 <- as.data.frame(
  new_data %>%
    group_by(Q10_2) %>%
    filter(!is.na(Q10_2))  %>%
    summarize(N = n()))

Q10_3 <- as.data.frame(
  new_data %>%
    group_by(Q10_3) %>%
    filter(!is.na(Q10_3))  %>%
    summarize(N = n()))


Q10_1_merged <- 
  Q10_1 %>%
  mutate(Q10_1 = case_when(Q10_1 %in% c("1","2", "3") ~ "1",
                        Q10_1 %in% "4" ~ "2",
                        Q10_1 %in% c("5","6", "7") ~ "3"))

Q10_2_merged <- 
  Q10_2 %>%
  mutate(Q10_2 = case_when(Q10_2 %in% c("1","2", "3") ~ "1",
                        Q10_2 %in% "4" ~ "2",
                        Q10_2 %in% c("5","6", "7") ~ "3"))

Q10_3_merged <- 
  Q10_3 %>%
  mutate(Q10_3 = case_when(Q10_3 %in% c("1","2", "3") ~ "1",
                        Q10_3 %in% "4" ~ "2",
                        Q10_3 %in% c("5","6", "7") ~ "3"))

Q10_1_new <- Q10_1_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q10_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_2_new <- Q10_2_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q10_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_3_new <- Q10_3_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q10_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q_10_1_p <- ggplot(Q10_1_new) +
  geom_bar(aes(factor(x=Q10_1), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q10_1), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד קידום בסולם הדרגות מבוסס על יכולת וניסיון")

Q_10_2_p <-ggplot(Q10_2_new) +
  geom_bar(aes(factor(x=Q10_2), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q10_2), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד השקעה ועבודה קשה מתוגמלות בקידום")

Q_10_3_p <-ggplot(Q10_3_new) +
  geom_bar(aes(factor(x=Q10_3), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q10_3), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד אנשים מקודמים על יסוד היכולת המוכחת שלהם לבצע את העבודה הנדרשת")

grid.arrange(Q_10_1_p, Q_10_2_p, Q_10_3_p, ncol = 1)

Perceptions of Meritiocracy (Past) by Seniority

Q10_1_37 <- as.data.frame(
  new_data %>%
    group_by(Q10_1, Q37) %>%
    filter(!is.na(Q10_1),!is.na(Q37))  %>%
    summarize(N = n()))

Q10_2_37 <- as.data.frame(
  new_data %>%
    group_by(Q10_2, Q37) %>%
    filter(!is.na(Q10_2),!is.na(Q37))  %>%
    summarize(N = n()))

Q10_3_37 <- as.data.frame(
  new_data %>%
    group_by(Q10_3, Q37) %>%
    filter(!is.na(Q10_3),!is.na(Q37))  %>%
    summarize(N = n()))
  
Q10_1_37_merged <- 
  Q10_1_37 %>%
  mutate(Q10_1 = case_when(Q10_1 %in% c("1","2", "3") ~ "1",
                        Q10_1 %in% "4" ~ "2",
                        Q10_1 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q10_2_37_merged <- 
  Q10_2_37 %>%
  mutate(Q10_2 = case_when(Q10_2 %in% c("1","2", "3") ~ "1",
                        Q10_2 %in% "4" ~ "2",
                        Q10_2 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q10_3_37_merged <- 
  Q10_3_37 %>%
  mutate(Q10_3 = case_when(Q10_3 %in% c("1","2", "3") ~ "1",
                        Q10_3 %in% "4" ~ "2",
                        Q10_3 %in% c("5","6", "7") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q10_1_37_merged_new <- Q10_1_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q10_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_2_37_merged_new <- Q10_2_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q10_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_3_37_merged_new <- Q10_3_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q10_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))


labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)


Q_10_1_p <- ggplot(Q10_1_37_merged_new) +
  geom_bar(aes(x=factor(Q10_1), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_1), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד קידום בסולם הדרגות מבוסס על יכולת וניסיון")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_10_2_p <- ggplot(Q10_2_37_merged_new) +
  geom_bar(aes(x=factor(Q10_2), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_2), y=freq, label = freq.lab),
            position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד השקעה ועבודה קשה מתוגמלות בקידום")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_10_3_p <- ggplot(Q10_3_37_merged_new) +
  geom_bar(aes(x=factor(Q10_3), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_3), y=freq,  label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד אנשים מקודמים על יסוד היכולת המוכחת שלהם לבצע את העבודה הנדרשת")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_10_1_p, Q_10_2_p, Q_10_3_p, ncol = 1)

Perceptions of Meritiocracy (Past) by Religion

Q10_1_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q10_1, Q41) %>%
    filter(!is.na(Q10_1),!is.na(Q41))  %>%
    summarize(N = n()))

Q10_2_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q10_2, Q41) %>%
    filter(!is.na(Q10_2),!is.na(Q41))  %>%
    summarize(N = n()))

Q10_3_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q10_3, Q41) %>%
    filter(!is.na(Q10_3),!is.na(Q41))  %>%
    summarize(N = n()))
  
Q10_1_41_merged <- 
  Q10_1_41 %>%
  mutate(Q10_1 = case_when(Q10_1 %in% c("1","2", "3") ~ "1",
                        Q10_1 %in% "4" ~ "2",
                        Q10_1 %in% c("5","6", "7") ~ "3"),
          Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q10_2_41_merged <- 
  Q10_2_41 %>%
  mutate(Q10_2 = case_when(Q10_2 %in% c("1","2", "3") ~ "1",
                        Q10_2 %in% "4" ~ "2",
                        Q10_2 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q10_3_41_merged <- 
  Q10_3_41 %>%
  mutate(Q10_3 = case_when(Q10_3 %in% c("1","2", "3") ~ "1",
                        Q10_3 %in% "4" ~ "2",
                        Q10_3 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q10_1_41_merged_new <- Q10_1_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q10_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_2_41_merged_new <- Q10_2_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q10_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q10_3_41_merged_new <- Q10_3_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q10_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)

Q_10_1_p <- ggplot(Q10_1_41_merged_new) +
  geom_bar(aes(x=factor(Q10_1), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_1), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
 ggtitle("במשרד בו אני עובד קידום בסולם הדרגות מבוסס על יכולת וניסיון")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_10_2_p <- ggplot(Q10_2_41_merged_new) +
  geom_bar(aes(x=factor(Q10_2), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_2), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד השקעה ועבודה קשה מתוגמלות בקידום")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_10_3_p <- ggplot(Q10_3_41_merged_new) +
  geom_bar(aes(x=factor(Q10_3), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q10_3), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במשרד בו אני עובד אנשים מקודמים על יסוד היכולת המוכחת שלהם לבצע את העבודה הנדרשת")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_10_1_p, Q_10_2_p, Q_10_3_p, ncol = 1)

Perceptions of Meritiocracy (Future)

Q11 <- as.data.frame(
  new_data %>%
    group_by(Q11) %>%
    filter(!is.na(Q11))  %>%
    summarize(N = n()))

Q11_merged <- 
  Q11 %>%
  mutate(Q11 = case_when(Q11 %in% c("1","2") ~ "1",
                        Q11 %in% "3" ~ "2",
                        Q11 %in% c("4","5") ~ "3"))

Q11_new <- Q11_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q11) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

ggplot(Q11_new) +
  geom_bar(aes(factor(x=Q11), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q11), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("שינוי לרעה ושינוי משמעותי לרעה", "ללא שינוי" ,"שינוי לטובה ושינוי משמעותי לטובה"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שיהיה שינוי לטובה\n ?או לרעה במידה שבה קידומים במשרד ייעשו בפועל על בסיס ניסיון רלוונטי, יכולת ועבודה קשה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Meritiocracy (Future) by Seniority

Q11_37 <- as.data.frame(
  new_data %>%
    group_by(Q11, Q37) %>%
    filter(!is.na(Q11),!is.na(Q37) )%>%
    summarize(N = n()))

Q11_37_merged <- 
  Q11_37 %>%
  mutate(Q11 = case_when(Q11 %in% c("1","2") ~ "1",
                        Q11 %in% "3" ~ "2",
                        Q11 %in% c("4","5") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q11_37_merged_new <- Q11_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q11) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)
ggplot(Q11_37_merged_new) +
  geom_bar(aes(x=factor(Q11), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q11), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("שינוי לרעה ושינוי משמעותי לרעה", "ללא שינוי" ,"שינוי לטובה ושינוי משמעותי לטובה"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שיהיה שינוי לטובה\n ?או לרעה במידה שבה קידומים במשרד ייעשו בפועל על בסיס ניסיון רלוונטי, יכולת ועבודה קשה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Meritiocracy (Future) by Religion

Q11_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q11, Q41) %>%
    filter(!is.na(Q11),!is.na(Q41))%>%
    summarize(N = n()))

Q11_41_merged <- 
  Q11_41 %>%
  mutate(Q11 = case_when(Q11 %in% c("1","2") ~ "1",
                        Q11 %in% "3" ~ "2",
                        Q11 %in% c("4","5") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q11_41_merged_new <- Q11_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q11) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  
ggplot(Q11_41_merged_new) +
  geom_bar(aes(x=factor(Q11), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q11), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("שינוי לרעה ושינוי משמעותי לרעה", "ללא שינוי" ,"שינוי לטובה ושינוי משמעותי לטובה"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("במבט קדימה על חמש השנים הבאות, באיזו מידה אתה צופה שיהיה שינוי לטובה\n ?או לרעה במידה שבה קידומים במשרד ייעשו בפועל על בסיס ניסיון רלוונטי, יכולת ועבודה קשה")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit Functioning

Q13 <- as.data.frame(
  new_data %>%
    group_by(Q13) %>%
    filter(!is.na(Q13))  %>%
    summarize(N = n()))

Q13_merged <- 
  Q13 %>%
  mutate(Q13 = case_when(Q13 %in% c("1","2") ~ "1",
                        Q13 %in% "3" ~ "2",
                        Q13 %in% c("4","5") ~ "3"))

Q13_new <- Q13_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q13) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))



ggplot(Q13_new) +
  geom_bar(aes(factor(x=Q13), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q13), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("באופן כללי, האם אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד\n ?לעצב ולקדם תכניות מדיניות שיענו על הצרכים של הציבור הישראלי")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit Functioning by Seniority

Q13_37 <- as.data.frame(
  new_data %>%
    group_by(Q13, Q37) %>%
    filter(!is.na(Q13),!is.na(Q37) )%>%
    summarize(N = n()))

Q13_37_merged <- 
  Q13_37 %>%
  mutate(Q13 = case_when(Q13 %in% c("1","2") ~ "1",
                        Q13 %in% "3" ~ "2",
                        Q13 %in% c("4","5") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q13_37_merged_new <- Q13_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q13) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)

ggplot(Q13_37_merged_new) +
  geom_bar(aes(x=factor(Q13), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q13), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("באופן כללי, האם אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד\n ?לעצב ולקדם תכניות מדיניות שיענו על הצרכים של הציבור הישראלי")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit Functioning by Religion

Q13_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q13, Q41) %>%
    filter(!is.na(Q13),!is.na(Q41) )%>%
    summarize(N = n()))

Q13_41_merged <- 
  Q13_41 %>%
  mutate(Q13 = case_when(Q13 %in% c("1","2") ~ "1",
                        Q13 %in% "3" ~ "2",
                        Q13 %in% c("4","5") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q13_41_merged_new <- Q13_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q13) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  
ggplot(Q13_41_merged_new) +
  geom_bar(aes(x=factor(Q13), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q13), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
   theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("באופן כללי, האם אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד\n ?לעצב ולקדם תכניות מדיניות שיענו על הצרכים של הציבור הישראלי")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit HR

Q14 <- as.data.frame(
  new_data %>%
    group_by(Q14) %>%
    filter(!is.na(Q14))  %>%
    summarize(N = n()))
  
Q14_merged <- 
  Q14 %>%
  mutate(Q14 = case_when(Q14 %in% c("1","2") ~ "1",
                        Q14 %in% "3" ~ "2",
                        Q14 %in% c("4","5") ~ "3"))

Q14_new <- Q14_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q14) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))



ggplot(Q14_new) +
  geom_bar(aes(factor(x=Q14), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q14), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("עד כמה אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד \n?למשוך ולשמר עובדים איכותיים")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit HR by Seniority

Q14_37 <- as.data.frame(
  new_data %>%
    group_by(Q14, Q37) %>%
    filter(!is.na(Q14),!is.na(Q37) )%>%
    summarize(N = n()))

Q14_37_merged <- 
  Q14_37 %>%
  mutate(Q14 = case_when(Q14 %in% c("1","2") ~ "1",
                        Q14 %in% "3" ~ "2",
                        Q14 %in% c("4","5") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q14_37_merged_new <- Q14_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q14) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)

ggplot(Q14_37_merged_new) +
  geom_bar(aes(x=factor(Q14), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q14), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
      ggtitle("עד כמה אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד \n?למשוך ולשמר עובדים איכותיים")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Unit Human Resources by Religion

Q14_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q14, Q41) %>%
    filter(!is.na(Q14),!is.na(Q41) )%>%
    summarize(N = n()) 
)

Q14_41_merged <- 
  Q14_41 %>%
  mutate(Q14 = case_when(Q14 %in% c("1","2") ~ "1",
                        Q14 %in% "3" ~ "2",
                        Q14 %in% c("4","5") ~ "3"),
        Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q14_41_merged_new <- Q14_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q14) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  
ggplot(Q14_41_merged_new) +
  geom_bar(aes(x=factor(Q14), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q14), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_fill_brewer(palette="Reds", labels=c("חילוני", "דתי")) +
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
      ggtitle("עד כמה אתה אופטימי או פסימי לגבי היכולת העתידית של המשרד שבו אתה עובד \n?למשוך ולשמר עובדים איכותיים")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Democracy (Future)

Q15 <- as.data.frame(
  new_data %>%
    group_by(Q15) %>%
    filter(!is.na(Q15))  %>%
    summarize(N = n()))

Q15_merged <- 
  Q15 %>%
  mutate(Q15 = case_when(Q15 %in% c("1","2") ~ "1",
                        Q15 %in% "999" ~ "2",
                        Q15 %in% c("3","4") ~ "3"))

Q15_new <- Q15_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q15) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))



ggplot(Q15_new) +
  geom_bar(aes(factor(x=Q15), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q15), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12, family="David"),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20, family="David"),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("?איך אתה מרגיש לגבי מצב השלטון הדמוקרטי בישראל בעתיד הנראה לעין")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

Perceptions of Democracy (Future) by Seniority

Q15_37 <- as.data.frame(
  new_data %>%
    group_by(Q15, Q37) %>%
    filter(!is.na(Q15),!is.na(Q37) )%>%
    summarize(N = n()))

Q15_37_merged <- 
  Q15_37 %>%
  mutate(Q15 = case_when(Q15 %in% c("1","2") ~ "1",
                        Q15 %in% "999" ~ "2",
                        Q15 %in% c("3","4") ~ "3"),
         Q37 = case_when(Q37 %in% c("1","2") ~ "1",
                        Q37 %in% c("3","4") ~ "2"))

Q15_37_merged_new <- Q15_37_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q37, Q15) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'דרג ביניים וזוטר',
  '2' = 'דרג בכיר ובכיר מאוד'
)

ggplot(Q15_37_merged_new) +
  geom_bar(aes(x=factor(Q15), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q15), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_fill_brewer(palette="Reds", labels=c("דרג ביניים וזוטר", "דרג בכיר ובכיר מאוד")) +
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q37, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
    ggtitle("?איך אתה מרגיש לגבי מצב השלטון הדמוקרטי בישראל בעתיד הנראה לעין")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Democracy (Future) by Religion

Q15_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q15, Q41) %>%
    filter(!is.na(Q15),!is.na(Q41) )%>%
    summarize(N = n()) 
)

Q15_41_merged <- 
  Q15_41 %>%
  mutate(Q15 = case_when(Q15 %in% c("1","2") ~ "1",
                        Q15 %in% "999" ~ "2",
                        Q15 %in% c("3","4") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q15_41_merged_new <- Q15_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q15) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  
ggplot(Q15_41_merged_new) +
  geom_bar(aes(x=factor(Q15), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q15), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("פסימי ופסימי מאוד", "לא פסימי ולא אופטימי" ,"אופטימי ואופטימי מאוד")) +
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_fill_brewer(palette="Reds", labels=c("חילוני", "דתי")) +
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
    ggtitle("?איך אתה מרגיש לגבי מצב השלטון הדמוקרטי בישראל בעתיד הנראה לעין")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Perceptions of Civil Service Exit

Perceptions of Exit from Civil Service by Seniority

Perceptions of Exit from Civil Service by Religion

Q26_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q26, Q41) %>%
    filter(!is.na(Q26),!is.na(Q41))%>%
    summarize(N = n()))

Q26_41_merged <- 
  Q26_41 %>%
  mutate(Q26 = case_when(Q26 %in% c("1","2") ~ "1",
                        Q26 %in% "3" ~ "2",
                        Q26 %in% c("4","5") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))


Q26_41_merged_new <- Q26_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q26) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)

ggplot(Q26_41_merged_new) +
  geom_bar(aes(x=factor(Q26), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=factor(Q26), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("נמוכה ונמוכה מאוד", "בינונית" ,"גבוהה וגבוהה מאוד"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_fill_brewer(palette="Reds", labels=c("חילוני", "דתי")) +
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
    ggtitle("לו הייתה מוצעת לך היום משרה מחוץ לשירות המדינה ברמת שכר דומה לזו שאתה מרוויח כיום\n ?מה הסבירות שהיית בוחר לעזוב את שירות המדינה")

Q28_1 <- as.data.frame(
  new_data %>%
    group_by(Q28_1) %>%
    filter(!is.na(Q28_1))  %>%
    summarize(N = n()))

Q28_2 <- as.data.frame(
  new_data %>%
    group_by(Q28_2) %>%
    filter(!is.na(Q28_2))  %>%
    summarize(N = n()))

Q28_3 <- as.data.frame(
  new_data %>%
    group_by(Q28_3) %>%
    filter(!is.na(Q28_3))  %>%
    summarize(N = n()))

Q28_4 <- as.data.frame(
  new_data %>%
    group_by(Q28_4) %>%
    filter(!is.na(Q28_4))  %>%
    summarize(N = n()))

Q28_1_merged <- 
  Q28_1 %>%
  mutate(Q28_1 = case_when(Q28_1 %in% c("1","2", "3") ~ "1",
                        Q28_1 %in% "4" ~ "2",
                        Q28_1 %in% c("5","6", "7") ~ "3"))

Q28_2_merged <- 
  Q28_2 %>%
  mutate(Q28_2 = case_when(Q28_2 %in% c("1","2", "3") ~ "1",
                        Q28_2 %in% "4" ~ "2",
                        Q28_2 %in% c("5","6", "7") ~ "3"))

Q28_3_merged <- 
  Q28_3 %>%
  mutate(Q28_3 = case_when(Q28_3 %in% c("1","2", "3") ~ "1",
                        Q28_3 %in% "4" ~ "2",
                        Q28_3 %in% c("5","6", "7") ~ "3"))

Q28_4_merged <- 
  Q28_4 %>%
  mutate(Q28_4 = case_when(Q28_4 %in% c("1","2", "3") ~ "1",
                        Q28_4 %in% "4" ~ "2",
                        Q28_4 %in% c("5","6", "7") ~ "3"))

Q28_1_new <- Q28_1_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q28_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_2_new <- Q28_2_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q28_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_3_new <- Q28_3_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q28_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_4_new <- Q28_4_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q28_4) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q_28_1_p <- ggplot(Q28_1_new) +
  geom_bar(aes(factor(x=Q28_1), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q28_1), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(breaks = c(0, 0.25, 0.5, 0.75, 1),
                     labels = scales::percent,
                     limits = c(0, 1)) +
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("חשוב לי לבצע שירות ציבורי משמעותי")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_28_2_p <-ggplot(Q28_2_new) +
  geom_bar(aes(factor(x=Q28_2), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q28_2), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("אני רואה בשירות הציבור את חובתי לחברה הישראלית")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_28_3_p <-ggplot(Q28_3_new) +
  geom_bar(aes(factor(x=Q28_3), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q28_3), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("תרומה לחברה הישראלית חשובה לי יותר מהישגים אישיים")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_28_4_p <-ggplot(Q28_4_new) +
  geom_bar(aes(factor(x=Q28_4), y=freq), stat="identity")+
  geom_text(aes(x=factor(Q28_4), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("אני מוכן לשאת במחיר אישי כבד לטובת החברה הישראלית")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_28_1_p, Q_28_2_p, Q_28_3_p, Q_28_4_p,ncol = 1)
Q28_1_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q28_1, Q41) %>%
    filter(!is.na(Q28_1),!is.na(Q41))  %>%
    summarize(N = n()))

Q28_2_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q28_2, Q41) %>%
    filter(!is.na(Q28_2),!is.na(Q41))  %>%
    summarize(N = n()))

Q28_3_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q28_3, Q41) %>%
    filter(!is.na(Q28_3),!is.na(Q41))  %>%
    summarize(N = n()))

Q28_4_41 <- as.data.frame(
  new_data %>%
    filter(Q41 != 999) %>%
    group_by(Q28_4, Q41) %>%
    filter(!is.na(Q28_4),!is.na(Q41))  %>%
    summarize(N = n()))
  
Q28_1_41_merged <- 
  Q28_1_41 %>%
  mutate(Q28_1 = case_when(Q28_1 %in% c("1","2", "3") ~ "1",
                        Q28_1 %in% "4" ~ "2",
                        Q28_1 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q28_2_41_merged <- 
  Q28_2_41 %>%
  mutate(Q28_2 = case_when(Q28_2 %in% c("1","2", "3") ~ "1",
                        Q28_2 %in% "4" ~ "2",
                        Q28_2 %in% c("5","6", "7") ~ "3"),
        Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q28_3_41_merged <- 
  Q28_3_41 %>%
  mutate(Q28_3 = case_when(Q28_3 %in% c("1","2", "3") ~ "1",
                        Q28_3 %in% "4" ~ "2",
                        Q28_3 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q28_4_41_merged <- 
  Q28_4_41 %>%
  mutate(Q28_4 = case_when(Q28_4 %in% c("1","2", "3") ~ "1",
                        Q28_4 %in% "4" ~ "2",
                        Q28_4 %in% c("5","6", "7") ~ "3"),
         Q41 = case_when(Q41 %in% c("0","1") ~ "1",
                         Q41 %in% c("2","3", "4") ~ "2"))

Q28_1_41_merged_new <- Q28_1_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q28_1) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_2_41_merged_new <- Q28_2_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q28_2) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_3_41_merged_new <- Q28_3_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q28_3) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

Q28_4_41_merged_new <- Q28_4_41_merged %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(Q41, Q28_4) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

labels = c(
  '1' = 'חילוני',
  '2' = 'דתי'
)
  

Q_28_1_p <- ggplot(Q28_1_41_merged_new) +
  geom_bar(aes(x=factor(Q28_1), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q28_1), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("חשוב לי לבצע שירות ציבורי משמעותי")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_28_2_p <- ggplot(Q28_2_41_merged_new) +
  geom_bar(aes(x=factor(Q28_2), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q28_2), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("אני רואה בשירות הציבור את חובתי לחברה הישראלית")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

Q_28_3_p <- ggplot(Q28_3_41_merged_new) +
  geom_bar(aes(x=factor(Q28_3), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q28_3), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("תרומה לחברה הישראלית חשובה לי יותר מהישגים אישיים")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`
  
Q_28_4_p <- ggplot(Q28_4_41_merged_new) +
  geom_bar(aes(x=factor(Q28_4), y=freq), stat="identity", position = "dodge")+
  geom_text(aes(x=(Q28_4), y=freq, label = freq.lab), position=position_dodge(width=0.9), vjust=-0.25)+
  scale_x_discrete(labels = c("לא מסכים", "מתלבט", "מסכים"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
 theme(strip.text = element_text(size=12),
        axis.text.x = element_text(angle = 45, hjust=1),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=14),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  facet_wrap(~Q41, labeller=as_labeller(labels))+
  xlab("")+
  ylab("")+
  ggtitle("אני מוכן לשאת במחיר אישי כבד לטובת החברה הישראלית")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`

grid.arrange(Q_28_1_p, Q_28_2_p, Q_28_3_p, Q_28_4_p, ncol = 1)

Summary Table

new_data$Q1_gender <- as.factor(new_data$Q1_gender)
levels(new_data$Q1_gender) <- c("גבר", "אישה", "אחר")
colnames(new_data)[19] <- "gender"

new_data$Q31_32 <- coalesce(new_data$Q31, new_data$Q32)
## Warning: `..1` and `..2` have conflicting value labels.
## i Labels for these values will be taken from `..1`.
## x Values: 15
new_data$Q31_32 <- as.factor(new_data$Q31_32)
levels(new_data$Q31_32) <- c("אנרגיה", "ביטחון", "ביטחון לאומי", "אוצר", "בינוי ושיכון", "בריאות", "הגנת הסביבה", "חוץ", "חינוך", "חקלאות", "כלכלה", "מדע וטכנולוגיה", "משפטים", "רווחה וביטחון חברתי", "עליה וקליטה", "פנים", "ראש הממשלה", "רשות האוכלוסין וההגירה", "שוויון חברתי", "שירותי דת", "תחבורה", "תיירות", "תקשורת", "תרבות וספורט", "אחר")
colnames(new_data)[88] <- "ministry"

new_data$Q33_34 <- coalesce(new_data$Q33, new_data$Q34)
new_data$Q33_34 <- as.factor(new_data$Q33_34)
levels(new_data$Q33_34) <- c("פחות משנה", "שנה עד חמש שנים", "שש עד עשר שנים", "אחת עשרה עד עשרים שנה", "למעלה מעשרים שנים")
colnames(new_data)[89] <- "seniority_years"

new_data$Q35_36 <- coalesce(new_data$Q35, new_data$Q36)
new_data$Q35_36 <- as.factor(new_data$Q35_36)
levels(new_data$Q35_36) <- c("משרת אמון", "מינוי במרכז", "ממלא מקום", "אחר")
colnames(new_data)[90] <- "appointing"

new_data$Q37_38 <- coalesce(new_data$Q37, new_data$Q38)
new_data$Q37_38 <- as.factor(new_data$Q37_38)
levels(new_data$Q37_38) <- c("זוטר", "ביניים", "בכיר", "בכיר מאוד")
colnames(new_data)[91] <- "seniority_perceived"

new_data$Q39 <- as.factor(new_data$Q39)
levels(new_data$Q39) <- c("יהודי", "לא יהודי")
colnames(new_data)[80] <- "nationality"

new_data$Q40 <- as.factor(new_data$Q40)
levels(new_data$Q40) <- c("20-30", "31-40", "41-50", "51-60", "61-")
colnames(new_data)[81] <- "age"

new_data$Q41 <- as.factor(new_data$Q41)
levels(new_data$Q41) <- c("חילוני", "מסורתי לא דתי", "מסורתי דתי", "דתי", "חרדי", "אחר")
colnames(new_data)[82] <- "religiosity"

new_data$Q42 <- as.factor(new_data$Q42)
levels(new_data$Q42) <- c("תיכונית", "תואר ראשון", "תואר שני", "תואר שלישי", "אחר")
colnames(new_data)[83] <- "education"

  new_data%>% 
    select(gender, ministry, seniority_years, appointing, seniority_perceived,
           nationality, age, religiosity, education) %>%
    tbl_summary(missing = "no")
Characteristic N = 9261
gender
    גבר 383 (46%)
    אישה 443 (53%)
    אחר 8 (1.0%)
ministry
    אנרגיה 14 (3.1%)
    ביטחון 6 (1.3%)
    ביטחון לאומי 8 (1.7%)
    אוצר 40 (8.7%)
    בינוי ושיכון 15 (3.3%)
    בריאות 36 (7.9%)
    הגנת הסביבה 9 (2.0%)
    חוץ 6 (1.3%)
    חינוך 24 (5.2%)
    חקלאות 8 (1.7%)
    כלכלה 35 (7.6%)
    מדע וטכנולוגיה 8 (1.7%)
    משפטים 61 (13%)
    רווחה וביטחון חברתי 37 (8.1%)
    עליה וקליטה 2 (0.4%)
    פנים 14 (3.1%)
    ראש הממשלה 37 (8.1%)
    רשות האוכלוסין וההגירה 1 (0.2%)
    שוויון חברתי 2 (0.4%)
    שירותי דת 1 (0.2%)
    תחבורה 13 (2.8%)
    תיירות 1 (0.2%)
    תקשורת 2 (0.4%)
    תרבות וספורט 2 (0.4%)
    אחר 76 (17%)
seniority_years
    פחות משנה 14 (2.9%)
    שנה עד חמש שנים 149 (31%)
    שש עד עשר שנים 123 (26%)
    אחת עשרה עד עשרים שנה 109 (23%)
    למעלה מעשרים שנים 80 (17%)
appointing
    משרת אמון 18 (3.8%)
    מינוי במרכז 400 (85%)
    ממלא מקום 18 (3.8%)
    אחר 36 (7.6%)
seniority_perceived
    זוטר 73 (16%)
    ביניים 226 (50%)
    בכיר 131 (29%)
    בכיר מאוד 23 (5.1%)
nationality
    יהודי 470 (99%)
    לא יהודי 4 (0.8%)
age
    20-30 51 (11%)
    31-40 171 (36%)
    41-50 161 (34%)
    51-60 70 (15%)
    61- 17 (3.6%)
religiosity
    חילוני 268 (57%)
    מסורתי לא דתי 50 (11%)
    מסורתי דתי 25 (5.3%)
    דתי 96 (20%)
    חרדי 22 (4.7%)
    אחר 10 (2.1%)
education
    תיכונית 4 (0.8%)
    תואר ראשון 77 (16%)
    תואר שני 347 (74%)
    תואר שלישי 35 (7.4%)
    אחר 9 (1.9%)
1 n (%)

Seniority (perceived) by Religiosity

  new_data %>%
    tbl_cross(row = seniority_perceived, col = religiosity, missing = "no") %>%
    bold_labels()
religiosity Total
חילוני מסורתי לא דתי מסורתי דתי דתי חרדי אחר
seniority_perceived
    זוטר 43 5 3 17 5 0 73
    ביניים 129 21 13 46 8 8 225
    בכיר 74 16 9 23 5 1 128
    בכיר מאוד 10 4 0 6 2 1 23
Total 256 46 25 92 20 10 449

Seniority (perceived) by Religiosity

  new_data %>%
    tbl_cross(row = seniority_perceived, col = gender, missing = "no") %>%
    bold_labels()
gender Total
גבר אישה אחר
seniority_perceived
    זוטר 29 44 0 73
    ביניים 97 128 1 226
    בכיר 61 70 0 131
    בכיר מאוד 14 9 0 23
Total 201 251 1 453

Survey Distribution


Q0 <- as.data.frame(
  new_data %>%
    group_by(how_recieve) %>%
    filter(!is.na(how_recieve))%>%
    summarize(N = n()))

Q0_new <- Q0 %>% 
  type.convert(as.is=TRUE) %>% 
  group_by(how_recieve) %>% 
  summarise(N=sum(N, na.rm = TRUE))%>% 
  mutate(freq = N / sum(N))%>% round(2)%>%
  mutate(freq.lab=str_c(100*freq,"%"))

ggplot(Q0_new) +
  geom_bar(aes(factor(x=how_recieve), y=freq), stat="identity")+
  geom_text(aes(x=factor(how_recieve), y=freq, label = freq.lab),vjust=-0.3,size=4)+
  scale_x_discrete(labels = c("ישירות מהחוקרים", "מוסד אקדמי", "עמית", "רשת חברתית"))+
  scale_y_continuous(labels = function(x) paste0(x*100, "%"), limits=c(0,1))+
  theme(strip.text = element_text(size=24),
        axis.text = element_text(size =12),
        axis.line = element_line(colour = "black"),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        legend.title=element_blank(),
        legend.text=element_text(size=20),
        legend.position='bottom',
        legend.direction ='horizontal',
        legend.key=element_blank(),
        legend.margin = unit(0.2, "line"),
        legend.key.height=unit(0.6,"line"), 
        plot.title=element_text(size=12,face="bold", hjust = 0.5),
        axis.title.x=element_text(size=24),
        axis.title.y=element_text(size=24))+
  xlab("")+
  ylab("")+
  ggtitle("?כיצד קיבלת את ההזמנה לסקר")
## Warning: `legend.margin` must be specified using `margin()`
## i For the old behavior use `legend.spacing`