soepisv36 <- rio::import(here::here("data/soepisv36.rds"))
soepis_long <- rio::import(here::here("data/soepis_long.rds"))
soepis_age <- rio::import(here::here("data/soepis_age.rds"))

1 Explore Frequency Tables for Gene Analyis

1.1 By Year

First you can see the number of available observation for each variable in each year

1.1.1 Variable Group: ID’s

soepis_long %>% 
      filter(key_category == "ID's") %>% 
      drop_na(value) %>%
      tabyl(syear, key) %>% adorn_totals(where = "col") %>% tbl_df()
# alternative version for blog?
# soepis_long %>% 
#       filter(key_category == "ID's") %>% 
#       drop_na(value) %>%
#       group_by(key, syear) %>% 
#       count() %>% 
#       pivot_wider(names_from = key, values_from = n) 

1.1.2 Variable Group: Survey

soepis_long %>% 
      filter(key_category == "Survey") %>% 
      drop_na(value) %>%
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.3 Variable Group: Demography

soepis_long %>% 
      filter(key_category == "Demography") %>% 
      drop_na(value) %>%
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4 Variable Group: Psych. Measures

1.1.4.1 Big5

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "b5_")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.2 Cognitive Test

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "cogtest")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.3 Forgiveness

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "forgive_")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.4 Autism

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "iabaut")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.5 Optimism, Selfworth, Trust

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "optimism|selfworth|trust")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.6 ???

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "iabm")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.4.7 Reciprocity

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "recip")) %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.1.5 Other

soepis_long %>% 
      drop_na(value) %>%
      filter(key_category == "Other") %>% 
      tabyl(key_name_label, syear) %>% adorn_totals(where = "col") %>% tbl_df()

1.2 By Age

1.2.1 Variable Group: ID’s

soepis_age %>% 
      filter(key_category == "ID's") %>% 
      drop_na(value) %>%
      tabyl(age_k, key) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.2 Variable Group: Survey

soepis_age %>% 
      filter(key_category == "Survey") %>% 
      drop_na(value) %>%
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.3 Variable Group: Demography

soepis_age %>% 
      filter(key_category == "Demography") %>% 
      drop_na(value) %>%
      tabyl(key_name_label, age_k)  %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4 Variable Group: Psych. Measures

1.2.4.1 Big5

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "b5_")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.2 Cognitive Test

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "cogtest")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.3 Forgiveness

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "forgive_")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.4 Autism

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "iabaut")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.5 Optimism, Selfworth, Trust

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "optimism|selfworth|trust")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.6 ???

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "iabm")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.4.7 Reciprocity

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Psych. Measure",
             str_detect(key, "recip_")) %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

1.2.5 Other

soepis_age %>% 
      drop_na(value) %>%
      filter(key_category == "Other") %>% 
      tabyl(key_name_label, age_k) %>% adorn_totals(where = "col") %>% tbl_df()

2 Supplement

2.1 resources