df.raw <- read_sav(file.path(here(), "Data", "personality 2016.sav")) %>%
  zap_labels() %>% zap_formats() %>% zap_widths() %>%
  mutate(
    KKKFrame_CivLibs.factor = factor(KKKFrame_CivLibs, 
                                     levels = 0:1, ordered = TRUE,
                                     labels = frame_labs_kkk_guns),
    GunFrame_CivLibs.factor = factor(GunFrame_CivLibs, 
                                     levels = 0:1, ordered = TRUE,
                                     labels = frame_labs_kkk_guns),
    StemCellsFrame_Positive.factor = factor(StemCellsFrame_Positive,
                                            levels = 0:1, ordered = TRUE,
                                            labels = frame_labs_stemcells),
    AAFrame_positive.factor = factor(AAFrame_positive, 
                                     levels = 0:1, ordered = TRUE,
                                     labels = frame_labs_aa),
    CancerResearchFrame_Positive.factor = factor(CancerResearchFrame_Positive,
                                                 levels = 0:1, ordered = TRUE,
                                                 labels = frame_labs_cancer)) %>%
  mutate(
    sex = factor(PPGENDER, levels = c(1, 0), ordered = TRUE,
                 labels = c("Male", "Female")),
    age_cat = factor(ppagect4, levels = 1:4, ordered = TRUE,
                     labels = c("18–29", "30–44", "45–59", "60+")),
    republican = factor(ifelse(PartyIDreduced == -1, "Republican", "Not Republican"),
                        ordered = TRUE, levels = c("Republican", "Not Republican")),
    democrat = factor(ifelse(PartyIDreduced == 1, "Democrat", "Not Democrat"),
                      ordered = TRUE, levels = c("Democrat", "Not Democrat")),
    race = factor(PPETHM, levels = c(1, 0), ordered = TRUE,
                  labels = c("White/non-Hispanic", "Other race specified")),
    education = factor(PPEDUCAT, levels = 1:4, ordered = TRUE,
                       labels = c(
                         "Less than high school", "High school",
                         "Some college", "Bachelor’s degree or above"))) %>%
  mutate_at(vars(sex, race, republican, democrat), funs(rev = fct_rev))

df.small <- df.raw %>%
  select(caseid, weight, 
         # DVs
         KKK_Support, Gun_Support, 
         StemCellsSupport, AASupport, CancerResearchSupport,
         # Frames
         KKKFrame_CivLibs, GunFrame_CivLibs, 
         StemCellsFrame_Positive, AAFrame_positive, 
         CancerResearchFrame_Positive,
         # Frames (as factors)
         KKKFrame_CivLibs.factor, GunFrame_CivLibs.factor,
         StemCellsFrame_Positive.factor, AAFrame_positive.factor, 
         CancerResearchFrame_Positive.factor,
         # Big 5
         OPENNESS, CONSCIENTIOUSNESS, EXTRAVERSION, AGREEABLENESS, NEUROTICISM,
         # Other traits
         POLITICAL_KNOWLEDGE, NC,
         # Main controls
         sex, race, age_cat, age = PPAGE, democrat, republican, education,
         sex_rev, race_rev, republican_rev, democrat_rev,
         # Other variables
         condition = XNANO)

saveRDS(df.small, file.path(here(), "Data", "survey_clean.rds"))
LS0tCnRpdGxlOiAiQ2xlYW4gZGF0YSIKYXV0aG9yOiAiTWVyZWRpdGggQ29ucm95IGFuZCBBbmRyZXcgSGVpc3MiCmRhdGU6ICJgciBmb3JtYXQoU3lzLnRpbWUoKSwgJyVCICVlLCAlWScpYCIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICBjb2RlX2ZvbGRpbmc6IHNob3cKZWRpdG9yX29wdGlvbnM6IAogIGNodW5rX291dHB1dF90eXBlOiBjb25zb2xlCi0tLQoKYGBge3Igc2V0dXAsIG1lc3NhZ2U9RkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChjYWNoZSA9IEZBTFNFLCBmaWcucmV0aW5hID0gMiwKICAgICAgICAgICAgICAgICAgICAgIHRpZHkub3B0cyA9IGxpc3Qod2lkdGguY3V0b2ZmID0gMTIwKSwgICMgRm9yIGNvZGUKICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gMTIwKSAgIyBGb3Igb3V0cHV0CmBgYAoKYGBge3IgbG9hZC1saWJyYXJpZXMsIG1lc3NhZ2U9RkFMU0UsIHdhcm5pbmc9RkFMU0V9CmxpYnJhcnkodGlkeXZlcnNlKQpsaWJyYXJ5KGhhdmVuKQpsaWJyYXJ5KGhlcmUpCgpzb3VyY2UoZmlsZS5wYXRoKGhlcmUoKSwgImxpYiIsICJsYWJlbHMuUiIpKQpgYGAKCmBgYHtyIGNsZWFuLWRhdGF9CmRmLnJhdyA8LSByZWFkX3NhdihmaWxlLnBhdGgoaGVyZSgpLCAiRGF0YSIsICJwZXJzb25hbGl0eSAyMDE2LnNhdiIpKSAlPiUKICB6YXBfbGFiZWxzKCkgJT4lIHphcF9mb3JtYXRzKCkgJT4lIHphcF93aWR0aHMoKSAlPiUKICBtdXRhdGUoCiAgICBLS0tGcmFtZV9DaXZMaWJzLmZhY3RvciA9IGZhY3RvcihLS0tGcmFtZV9DaXZMaWJzLCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldmVscyA9IDA6MSwgb3JkZXJlZCA9IFRSVUUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYWJlbHMgPSBmcmFtZV9sYWJzX2tra19ndW5zKSwKICAgIEd1bkZyYW1lX0NpdkxpYnMuZmFjdG9yID0gZmFjdG9yKEd1bkZyYW1lX0NpdkxpYnMsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV2ZWxzID0gMDoxLCBvcmRlcmVkID0gVFJVRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhYmVscyA9IGZyYW1lX2xhYnNfa2trX2d1bnMpLAogICAgU3RlbUNlbGxzRnJhbWVfUG9zaXRpdmUuZmFjdG9yID0gZmFjdG9yKFN0ZW1DZWxsc0ZyYW1lX1Bvc2l0aXZlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldmVscyA9IDA6MSwgb3JkZXJlZCA9IFRSVUUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFiZWxzID0gZnJhbWVfbGFic19zdGVtY2VsbHMpLAogICAgQUFGcmFtZV9wb3NpdGl2ZS5mYWN0b3IgPSBmYWN0b3IoQUFGcmFtZV9wb3NpdGl2ZSwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbHMgPSAwOjEsIG9yZGVyZWQgPSBUUlVFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFiZWxzID0gZnJhbWVfbGFic19hYSksCiAgICBDYW5jZXJSZXNlYXJjaEZyYW1lX1Bvc2l0aXZlLmZhY3RvciA9IGZhY3RvcihDYW5jZXJSZXNlYXJjaEZyYW1lX1Bvc2l0aXZlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV2ZWxzID0gMDoxLCBvcmRlcmVkID0gVFJVRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhYmVscyA9IGZyYW1lX2xhYnNfY2FuY2VyKSkgJT4lCiAgbXV0YXRlKAogICAgc2V4ID0gZmFjdG9yKFBQR0VOREVSLCBsZXZlbHMgPSBjKDEsIDApLCBvcmRlcmVkID0gVFJVRSwKICAgICAgICAgICAgICAgICBsYWJlbHMgPSBjKCJNYWxlIiwgIkZlbWFsZSIpKSwKICAgIGFnZV9jYXQgPSBmYWN0b3IocHBhZ2VjdDQsIGxldmVscyA9IDE6NCwgb3JkZXJlZCA9IFRSVUUsCiAgICAgICAgICAgICAgICAgICAgIGxhYmVscyA9IGMoIjE44oCTMjkiLCAiMzDigJM0NCIsICI0NeKAkzU5IiwgIjYwKyIpKSwKICAgIHJlcHVibGljYW4gPSBmYWN0b3IoaWZlbHNlKFBhcnR5SURyZWR1Y2VkID09IC0xLCAiUmVwdWJsaWNhbiIsICJOb3QgUmVwdWJsaWNhbiIpLAogICAgICAgICAgICAgICAgICAgICAgICBvcmRlcmVkID0gVFJVRSwgbGV2ZWxzID0gYygiUmVwdWJsaWNhbiIsICJOb3QgUmVwdWJsaWNhbiIpKSwKICAgIGRlbW9jcmF0ID0gZmFjdG9yKGlmZWxzZShQYXJ0eUlEcmVkdWNlZCA9PSAxLCAiRGVtb2NyYXQiLCAiTm90IERlbW9jcmF0IiksCiAgICAgICAgICAgICAgICAgICAgICBvcmRlcmV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