packages <- c(“tidyverse”, “modelsummary”, “forcats”, “RColorBrewer”, “fst”, “viridis”, “knitr”, “kableExtra”, “rmarkdown”, “ggridges”, “viridis”, “questionr”)

new_packages <- packages[!(packages %in% installed.packages()[,“Package”])] if(length(new_packages)) install.packages(new_packages) lapply(packages, library, character.only = TRUE) ess <- read_fst(“All-ESS-Data.fst”) setwd(‘C:/Users/evand/Desktop/SOC202’) getwd()

#———- # TASK 1 # ———

table(ess\(prtyban) # Ban political parties that wish to overthrow democracy table(ess\)polactiv) # Do you think you could take an active role in a group involved with political issues? table(ess$stfeco) # How satisfied are you with the present state of economy in your country?

gb_data <- ess %>% # filter(cntry == “GB”) %>% mutate( prtyban = ifelse(prtyban %in% c(7, 8, 9), NA, prtyban), polactiv = ifelse(polactiv %in% c(7, 8, 9), NA, polactiv), stfeco = ifelse(stfeco %in% c(77, 88, 99), NA, stfeco) )

datasummary_skim(gb_data %>% select(prtyban, polactiv, stfeco))

I note that the variable stfeco has a slightly normal distribution in the bar chart and has a much higher mean than

the other two variables presented, but this can likely be attributed to the fact that there is double the maximum value

of stfeco than the other variables.

———-

TASK 2

———-

I will use stfeco (How satisfied are you with the present state of economy in your country?) as my main variable.

table(ess\(essround) ess\)year <- NA replacements <- c(2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018, 2020) for(i in 1:10){ ess\(year[ess\)essround == i] <- replacements[i] }

eco_by <- gb_data %>% group_by(year) %>% summarize(mean_sat = mean(stfeco, na.rm = TRUE))

ggplot(eco_by, aes(x = year, y = mean_sat)) + geom_line(color = “blue”, size = 1) + # Line to show the trend geom_point(color = “red”, size = 3) + # Points to highlight each year’s value labs(title = “Satisfaction With the Present State of Economy in Great Britain (2002-2020)”, x = “Survey Year”, y = “Satisfaction (0-10)”) + ylim(0, 10) + # Setting the y-axis limits from 0 to 10 theme_minimal()

Regarding the table created, I notice that between the years 2005 and 2010 there was a steep decline in satisfaction

with the state of economics in Great Britain, which can be likely attributed to Great Britain’s Great Recession.

———-

TASK 3

———-

task3_cntry <- ess %>% filter(cntry %in% c(“FR”, “GB”, “NL”)) %>% mutate(stfeco = ifelse(stfeco %in% c(77, 88, 99), NA, stfeco))

task3plot <- ggplot(task3_cntry, aes(x = reorder(cntry, -stfeco, FUN=median), y = stfeco, fill = cntry)) + geom_boxplot() + theme_minimal() + theme(legend.position = “none”) + labs(title = “Boxplot comparison for satisfaction with the present state of economy (France, Great Britai, Netherlands)”, x = “Country”, y = “Scale (0-10)”) task3plot

I note that the Netherlands reports the highest satisfaction with the present state of economy, especially compared to France

which does not have values above 5.

———-

TASK 4

———-

gb_data <- gb_data %>% mutate(religion = case_when( rlgblg == 2 ~ “No”, rlgblg == 1 ~ “Yes”, rlgblg %in% c(7, 8, 9) ~ NA_character_, TRUE ~ as.character(rlgblg) ))

gb_data <- gb_data %>% mutate(born_in_country = recode(brncntr, 1 = “Yes”, 2 = “No”, 7 = NA_character_, 8 = NA_character_,

stfecorel <- datasummary_crosstab(stfeco ~ religion, data = gb_data)

proptable <- table(gb_data\(stfeco, gb_data\)religion) cprop(proptable)

proptable2 <- table(gb_data\(stfeco, gb_data\)born_in_country) cprop(proptable2)

I note that among those who describe themselves as religious, the most selected response was 5, meaning they are between both

ends of the satisfaction spectrum. This reflects my observation that the table is relatively evenly distributed, being slightly

skewed towards left-centred. Within the second table, I observe that those who were not born in Great Britain are more satisfied

with the state of the economy than those who are born in the country.

———-

TASK 5

———-

gb_clean <- gb_data %>% filter(!is.na(religion) & !is.na(stfeco))

gb_probs <- gb_clean %>% count(stfeco, religion) %>% group_by(religion) %>% mutate(prob = n / sum(n))

ggplot(gb_probs, aes(x = as.factor(stfeco), y = prob, color = religion)) + geom_point() + geom_line(aes(group = religion)) + labs(title = “Conditional Probabilities of Satisfaction With the Present Economic State”, subtitle = “by Belonging to a religion or denomination”, x = “Satisfaction”, y = “Probability”) + theme_minimal()

I note that there is a very similar report of satisfaction with the economy from religious and non-religious individuals, but

there is a much lower conditional probability from both groups of being extremely or very satisfied with the economy, relative

to being extremely unsatisfied or very unsatisfied with the economy.