#Do a data summary table of three variables of interest. Discuss briefly what you note (i.e., add text in your markdown after the Task 1 code).
#Variable 1: badge - Worn or displayed campaign badge/sticker last 12 months https://ess-search.nsd.no/en/variable/cd2e3204-99c6-4ede-89a8-a92ac54ff774
#Variable 2: netusoft - Internet use, how often https://ess-search.nsd.no/en/variable/49fcf969-aeab-42f5-9b11-807cb2306df0
#Variable 3:polintr - How interested in politics https://ess-search.nsd.no/en/variable/f08a0d6a-a5bf-42d4-9565-80fe44673914
#findings: badge is right skewed, with badge having a small outlier. polintr is normal, and netusoft is left skewed/.
#interestingly, netusoft has a high missing percentage. going into the data, I could not find a definite reason why. However, I can guess this may be because it is new variable, first being introduced in 2016.
#polintr has the biggest range, from 2-4, while netusoft has the smallest 5-5.
TASK 2
#Choose one of the three variables you just summarized in the table. This will be your current main outcome of interest.
# Produce a visual that showcases the mean (average) for your outcome of interest by survey year (can be, e.g., point + line plot or ridge plot, depending on your variable). Discuss briefly what you note (i.e., add text in your markdown after the Task 2 code).
sweden_data %>%
ggplot(aes(x = polintr, y = as.factor(year), fill = as.factor(year))) +
geom_density_ridges() +
labs(title = "How interested in politics - Sweden",
x = "Very Interested - Not at all Interested (1-4)", y = "Survey Year",
fill = "Survey Year") +
theme_minimal()
# The graph has stayed consistent with its peaks, with 2018 being the year with the least amount of people not being interested in politics, and more being very interested.The biggest group in every year has been "Quite Interested".
TASK 3
# Provide a comparison visual of your outcome of interest with two other countries. You can choose the geom() you prefer. Discuss briefly what you note (i.e., add text in your markdown after the Task 3 code).
t3countries <- ess %>%
filter(cntry %in% c("SE", "HU", "GB")) %>%
mutate(polintr = ifelse(polintr %in% c(7, 8, 9), NA, polintr))
t3plot <- ggplot(t3countries, aes(x = reorder(cntry, -polintr, FUN=median), y = polintr, fill = cntry)) +
geom_boxplot() +
theme_minimal() +
theme(legend.position = "none") +
labs(title = "Boxplot Comparison for How Interested in Politics (Sweden, Hungary, Great Britian)",
x = "Country",
y = "Very Interested - Not at all Interested (1-4)")
t3plot
# Great Britian and Sweden are consistent with eachother, having the same distribution, IQR, and median and no outliers. For every country, the minimum and maximum is the same. However, Hungary's median is higher than Great Britian's and Sweden's, indicating that more people are not interested in politics. Its IQR also adds to this finding, with Q3 ending on 4 - Not at All Interested.
TASK 4
# Produce a cross-tab between your outcome of interest and a socio-demographic variable (use datasummary_crosstab). Then, calculate column percentages using cprop(), making sure to pick a second socio-demographic variable. Discuss briefly what you note (i.e., add text in your markdown after the Task 4 code).
##
## No Yes All
## 1 9.1 15.3 14.7
## 2 34.3 47.6 46.3
## 3 34.2 28.5 29.1
## 4 22.3 8.6 9.9
## Total 100.0 100.0 100.0
# People are likeler to be more interested in a politics if they are religious. They are less likely to be interested in politics if they have never had a paid job. For all groupings, 2, "Quite Interested" in politics hold the greatest group.
TASK 5
#Choose one of the two socio-demographic variables you just worked with. Visualize the conditional probability (or column percentages) of your outcome given your selected socio-dem variable. Discuss briefly what you note (i.e., add text in your markdown after the Task 5 code).
df <- sweden_data %>%
filter(!is.na(paidjob) & !is.na(polintr))
df <- df %>%
mutate(polintr = case_when(
polintr == 1 ~ "Very Interested",
polintr == 2 ~ "Quite Interested",
polintr == 3 ~ "Hardly Interested",
polintr == 4 ~ "Not At All Interested",
TRUE ~ as.character(polintr) # or "Other", or NA_character_, depending on your needs
))
table(df$polintr)
##
## Hardly Interested Not At All Interested Quite Interested
## 2024 691 3222
## Very Interested
## 1024
table(df$polintr, df$paidjob) %>%
cprop() %>%
as.data.frame() %>%
filter(Var1 != "Total",
Var2 != "All") %>%
ggplot(aes(x=Var1, y=Freq, fill=Var2)) +
geom_col(position = "dodge") +
labs(title="How Interested in Politics in Sweden",
y = "Conditional Percentage",
x = "How Interested",
fill = "Ever Had a Paid Job vs. Not")
# People who have not held a paid job are overall less interested in politics. The groups for No and Yes are switched in the X-axis for Not At All Interested/Very Interested, with Very Interested beng smallest Group, and Quite Interested being the highest. This chart differs from the Joy Plot (unsure of the actual name), as the Hardly Interested demographic has a much higher conditional percentage here, than in the Joy Plot, although Quite Interested remains the largest demographic