library(tidyverse)
library(haven)
library(ggthemes)
library(scales)
ggplot_scale <- c("navyblue", "tan4", "chartreuse4", "blueviolet", "blue", "deeppink4", "goldenrod", "violetred", "turquoise2", "lightgreen", "lightpink1", "yellow1", "slategrey", "peachpuff2", "mediumorchid4", "mediumspringgreen", "tomato")

Data Wrangling

wvs <- read_sav("data/world-values-survey.sav")
wvs_mexico <- wvs %>% filter(v1 == 484)

# make an id row for plotting
wvs_mexico$id <- seq_len(nrow(wvs_mexico))
wvs_mexico$respondents <- "respondents"

# 1 = Male; 2 = Female
wvs_mexico <- wvs_mexico %>%
  mutate(
    gender = ifelse(v223 == 1, "Male", "Female")
  )

Questions

  1. What is the median age of this group?
median(wvs_mexico$v225, na.rm=TRUE)
## [1] 36
ggplot(wvs_mexico %>% filter(!is.na(v225))) +
  geom_density(aes(as.numeric(v225), colour=gender)) +
  theme_classic() +
  labs(x="Age", y="Density", 
       title="World Values Survey - Mexico - Age Distribution") +
  scale_color_manual(values=ggplot_scale)

ggsave("fig-age-density.png")
## Saving 7 x 5 in image
  1. What percentage of respondents were female vs. what percentage were male?
pct_female <- as.numeric(round(count(wvs_mexico %>% filter(gender=="Female")) / nrow(wvs_mexico), 2)) * 100

pct_male <- as.numeric(round(count(wvs_mexico %>% filter(gender=="Male")) / nrow(wvs_mexico), 2)) * 100

paste("Female %:", pct_female, "Male %:", pct_male)
## [1] "Female %: 55 Male %: 45"
ggplot(wvs_mexico, mapping = aes(x = respondents)) +
  geom_bar(aes(y = (..count..)/nrow(wvs_mexico),
           fill = gender),
           position="stack") +
  theme_classic() +
  scale_fill_manual(values=ggplot_scale) +
  scale_y_continuous(labels=scales::percent) +
  labs(y = "Percent of Respondents", x="")

ggsave("fig-gender-1.png")
## Saving 3 x 3 in image
ggplot(wvs_mexico, mapping = aes(x = gender)) +
  geom_bar(aes(y = (..count..)/nrow(wvs_mexico),
           fill = gender),
           position="stack") +
  theme_classic() +
  scale_fill_manual(values=ggplot_scale) +
  scale_y_continuous(labels=scales::percent, breaks=breaks_pretty()) +
  labs(y = "Percent of Respondents", x="")

ggsave("fig-gender-2.png")
## Saving 3 x 3 in image
  1. What percentage of Mexicans reported that:
  1. when jobs are scarce, men had more right to a job than women?
#v84
# agree, neither, disagree

men_job <- read_csv('
1,Agree
2,Neither
3,Disagree
', col_names=c("v84","v84_1"))

wvs_mexico <- wvs_mexico %>% full_join(men_job)
## Joining, by = "v84"
ggplot(wvs_mexico, mapping = aes(x = v84_1)) +
  geom_bar(aes(y = (..count..)/nrow(wvs_mexico),
           fill = gender)) +
  theme_classic() +
  scale_fill_manual(values=ggplot_scale) +
  scale_y_continuous(labels=scales::percent, 
                     breaks=breaks_pretty()) +
  labs(y = "Percent of Respondents", x="", 
       title = "Men have more right to a job when scarce")

ggsave("fig-men-job.png")
## Saving 7 x 5 in image
  1. a boy’s university education is more important than girls?
#v114

boy_uni <- read_csv('
1,Strongly Agree
2,Agree
3,Disagree
4,Strongly Agree
', col_names=c("v114","v114_1"))

wvs_mexico <- wvs_mexico %>% full_join(boy_uni)
## Joining, by = "v114"
ggplot(wvs_mexico, mapping = aes(x = v114_1)) +
  geom_bar(aes(y = (..count..)/nrow(wvs_mexico),
           fill = gender)) +
  theme_classic() +
  scale_fill_manual(values=ggplot_scale) +
  scale_y_continuous(labels=scales::percent, 
                     breaks=breaks_pretty()) +
  labs(y = "Percent of Respondents", x="", 
       title = "University is more important for a boy")

ggsave("fig-boy-uni.png")
## Saving 7 x 5 in image
  1. divorce was NEVER justifiable?
#v211 == 1

ggplot(wvs_mexico, mapping = aes(x = as.factor(v211))) +
  geom_bar(aes(y = (..count..)/nrow(wvs_mexico),
           fill = gender)) +
  theme_classic() +
  scale_fill_manual(values=ggplot_scale) +
  scale_y_continuous(labels=scales::percent, 
                     breaks=breaks_pretty()) +
  labs(y = "Percent of Respondents", x="", 
       title = "Is Divorce Justifiable? (1 is NEVER)")

ggsave("fig-divorce.png")
## Saving 7 x 5 in image
  1. That approve of women as single parents?

Can’t find this one, it says “V111” but that doesn’t match the sample questionnaire.

  1. a woman has to have children to be fulfilled?

Can’t find this one, it says “V110” but that doesn’t match the sample questionnaire.

  1. Concerning these attitudes about women’s rights, run the data again…this time comparing men vs. women. Present any big differences between men vs. women.

Already included in plots above.