Created
September 25, 2025 05:44
-
-
Save thoughtfulbloke/538864ad7704e689a48e37ef75ca1721 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(readr) | |
| library(dplyr) | |
| library(tidyr) | |
| library(ggplot2) | |
| library(ggthemes) | |
| source("~/theme.R") | |
| WVS <- read_csv("~/Downloads/WVS_Cross-National_Wave_7_csv_v6_0.csv") | |
| shorter <- WVS |> | |
| filter(B_COUNTRY_ALPHA %in% c("DEU", "RUS","IND", "USA", "KOR", "NZL")) |> | |
| select(B_COUNTRY_ALPHA, Q7:Q17) | |
| summarised <- shorter |> | |
| summarise(.by=B_COUNTRY_ALPHA, | |
| `Good manners` = 100 * sum(Q7==1, na.rm=TRUE)/sum(!is.na(Q7)), | |
| `Independence` = 100 * sum(Q8==1, na.rm=TRUE)/sum(!is.na(Q8)), | |
| `Hard work` = 100 * sum(Q9==1, na.rm=TRUE)/sum(!is.na(Q9)), | |
| `Feeling of responsibily` = 100 * sum(Q10==1, na.rm=TRUE)/sum(!is.na(Q10)), | |
| `Imagination` = 100 * sum(Q11==1, na.rm=TRUE)/sum(!is.na(Q11)), | |
| `Tolerance and respect for others` = 100 * sum(Q12==1, na.rm=TRUE)/sum(!is.na(Q12)), | |
| `Thrift saving money and things` = 100 * sum(Q13==1, na.rm=TRUE)/sum(!is.na(Q13)), | |
| `Determination Perserverance` = 100 * sum(Q14==1, na.rm=TRUE)/sum(!is.na(Q14)), | |
| `Religious Faith` = 100 * sum(Q15==1, na.rm=TRUE)/sum(!is.na(Q15)), | |
| `Unselfishness` = 100 * sum(Q16==1, na.rm=TRUE)/sum(!is.na(Q16)), | |
| `Obedience` = 100 * sum(Q17==1, na.rm=TRUE)/sum(!is.na(Q17))) |> | |
| pivot_longer(names_to = "Question", values_to = "percent", `Good manners`:`Obedience`) |> | |
| mutate(Country = factor(B_COUNTRY_ALPHA), | |
| Question = factor(Question)) | |
| ggplot(summarised, aes(y=Question, x=percent)) + | |
| geom_vline(xintercept = 50, colour="#EEEEEE") + | |
| geom_col() + | |
| facet_wrap(~Country, nrow=1) + | |
| theme_davidhood() + | |
| labs(title="Important Child Qualities", | |
| subtitle="Percent of country's respondents in World Values Survey wave 7 mentioning a quality", | |
| y="Quality", x="") | |
| ggsave(filename="~/Desktop/wvs.jpg", | |
| height=4.5, width = 8, dpi=150, units = "in", bg = "white") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment