library(tidyverse)
library(targets)
library(kableExtra)
library(glue)
library(scales)
library(janitor)
library(here)

# Generated via random.org
set.seed(8316)

# Load data
# Need to use this withr thing because tar_read() and tar_load() need to see the
# _targets folder in the current directory, but this .Rmd file is in a subfolder
withr::with_dir(here::here(), {
  tar_load(personas)
  tar_load(orgs)
  tar_load(sim_final)
  tar_load(survey_results)
  tar_load(participant_summary)
})

Organization attributes

All possible conjoint attributes

orgs$org_attributes %>% 
  select(Organization, `Issue area`, `Organizational practices`, `Funding sources`, `Relationship with government`) %>% 
  kbl(align = "lllll",
      caption = "Organization attributes varied in the experiment") %>% 
  kable_styling()
Organization attributes varied in the experiment
Organization Issue area Organizational practices Funding sources Relationship with government
Amnesty International Emergency response Financial transparency Small private donors Friendly
Greenpeace Environment Accountability Wealthy donors Criticized
Oxfam Human rights Government grants Crackdown
Red Cross Refugee relief

Attributes varied in simulation

orgs$org_attributes %>% 
  select(`Issue area`, `Relationship with government`, `Funding`) %>% 
  kbl(align = "lll",
      caption = "Organization attributes varied in the simulation, resulting in 24 hypothetical organizations") %>% 
  kable_styling()
Organization attributes varied in the simulation, resulting in 24 hypothetical organizations
Issue area Relationship with government Funding
Emergency response Friendly Small private donors
Environment Criticized Government grants
Human rights Crackdown
Refugee relief

Persona attributes

Attributes varied in simulation

personas$persona_attributes %>% 
  kbl(align = "lll",
      caption = "Individual attributes varied in the simulation, resulting in 64 persona profiles") %>% 
  kable_styling()
Individual attributes varied in the simulation, resulting in 64 persona profiles
Demographics Politics and public affairs Social views
Higher income (> US median ($61,372)), high school graduate, frequent religious attendance Liberal (1), follows national and international news often, has traveled internationally High social trust: Trusts political institutions, trusts charities, thinks people should be more charitable, frequently volunteers, donates once a month, has a history of personal activism, is a member of an association
Lower income (< US median), high school graduate, frequent religious attendance Conservative (7), follows news, has traveled Low social trust: Does not trust political institutions or charities, thinks people should be less charitable, does not volunteer or donate often, has no history of personal activism, is not a member of an association
Higher income, college graduate, frequent religious attendance Liberal, does not follow news, has not traveled
Lower income, college graduate, frequent religious attendance Conservative, does not follow news, has not traveled
Higher income, high school graduate, rare religious attendance
Lower income, high school graduate, rare religious attendance
Higher income, college graduate, rare religious attendance
Lower income, college graduate, rare religious attendance

Example simulation output

example_personas <- c("persona2", "persona63")

example_persona_details <- sim_final %>%
  filter(persona_id %in% example_personas) %>% 
  select(starts_with("persona")) %>% 
  slice(1:2)

example_persona_details %>% 
  select(-persona_id) %>% 
  pivot_longer(cols = !persona) %>% 
  pivot_wider(names_from = "persona", values_from = "value") %>% 
  select(-name) %>% 
  kbl(align = "ll",
      caption = "Example personas") %>% 
  kable_styling()
Example personas
Persona 2 Persona 63
Lower income Higher income
High school graduate College graduate
Rarely attends religious services Attends at least monthly
Liberal Conservative
Follows the news; has travelled abroad Doesn’t follow news; has not travelled abroad
Less trusting; donates and volunteers less often More trusting; donates and volunteers often
example_persona_results <- sim_final %>% 
  filter(persona_id %in% example_personas) %>% 
  mutate(org_funding = str_to_sentence(str_remove(org_funding, "Mostly funded by "))) %>% 
  mutate(org_clean = glue("{organization}: {org_issue}, {org_funding}, {org_relationship}")) %>% 
  mutate(persona_desc = recode(
    persona_id,
    "persona2" = "Lower income high school graduate who rarely attends religious services; liberal who reads and travels; doesn't trust or donate",
    "persona63" = "Higher income college graduate who attends religious services; conservative who doesn't read or travel; trusts and donates")
  ) %>%
  mutate(persona_clean = glue("{persona}: {persona_desc}")) %>% 
  select(persona_clean, share, org_clean) %>% 
  pivot_wider(names_from = "persona_clean", values_from = "share") %>% 
  adorn_totals(where = "row", name = "Total")

example_persona_results_small <- example_persona_results %>% 
  slice(c(1, 2, 3, 7, 8, 9, 16, 17, 25)) %>% 
  mutate(across(where(is.numeric), ~ percent_format(accuracy = 0.1)(.))) %>% 
  add_row(org_clean = "…", .after = 3) %>% 
  add_row(org_clean = "…", .after = 7) %>% 
  add_row(org_clean = "…", .after = 10) %>% 
  mutate(across(everything(), ~replace_na(., "…"))) %>% 
  rename(Organization = org_clean)

example_persona_results_small %>% 
  mutate(Organization = text_spec(Organization, bold = Organization == "Total")) %>% 
  kbl(align = "lcc",
      caption = "Sample simulation output",
      escape = FALSE) %>% 
  kable_styling()
Sample simulation output
Organization Persona 2: Lower income high school graduate who rarely attends religious services; liberal who reads and travels; doesn’t trust or donate Persona 63: Higher income college graduate who attends religious services; conservative who doesn’t read or travel; trusts and donates
Org 1: Emergency response, Small donors, Friendly 11.4% 3.3%
Org 2: Emergency response, Government grants, Friendly 7.2% 11.1%
Org 3: Emergency response, Small donors, Criticized 1.1% 1.3%
Org 7: Environment, Small donors, Friendly 10.2% 1.6%
Org 8: Environment, Government grants, Friendly 6.5% 5.2%
Org 9: Environment, Small donors, Criticized 1.0% 0.6%
Org 16: Human rights, Government grants, Criticized 0.7% 6.8%
Org 17: Human rights, Small donors, Under crackdown 0.9% 2.0%
Total 100.0% 100.0%

Sample details

participant_summary %>% 
  select(Question = clean_name,
         Response = level,
         N = count,
         `%` = nice_prop) %>% 
  kbl(align = "lllcc",
      caption = "Summary of individual respondent characteristics") %>% 
  pack_rows(index = table(fct_inorder(participant_summary$category))) %>%
  collapse_rows(columns = 1, valign = "top") %>% 
  kable_styling()
Summary of individual respondent characteristics
Question Response N %
Demographics
Gender Male 517 50.89%
Female 485 47.74%
Transgender 8 0.79%
Prefer not to say 3 0.30%
Other 3 0.30%
Age Less than 2017 national median (36) 179 18%
More than median 837 82%
Marital status Married 403 39.7%
Widowed 21 2.1%
Divorced 104 10.2%
Separated 35 3.4%
Never married 453 44.6%
Education Less than high school 25 2.5%
High school graduate 270 26.6%
Some college 287 28.2%
2 year degree 138 13.6%
4 year degree 206 20.3%
Graduate or professional degree 82 8.1%
Doctorate 8 0.8%
Income Less than 2017 national median ($61,372) 585 58%
More than median 431 42%
Attitudes toward charity
Frequency of donating to charity More than once a month, less than once a year 566 56%
At least once a month 450 44%
Amount of donations to charity last year $1-$49 337 33.17%
$50-$99 245 24.11%
$100-$499 233 22.93%
$500-$999 107 10.53%
$1000-$4,999 65 6.40%
$5000-$9,999 18 1.77%
$10,000+ 11 1.08%
Importance of trusting charities 1 (not important) 7 0.69%
2 9 0.89%
3 21 2.07%
4 98 9.65%
5 168 16.54%
6 157 15.45%
7 (important) 556 54.72%
Level of trust in charities 1 (no trust) 14 1.38%
2 20 1.97%
3 68 6.69%
4 257 25.30%
5 328 32.28%
6 169 16.63%
7 (complete trust) 160 15.75%
Frequency of volunteering Haven’t volunteered in past 12 months 423 41.6%
Rarely 20 2.0%
More than once a month, less than once a year 322 31.7%
At least once a month 251 24.7%
Politics, ideology, and religion
Frequency of following national news Rarely 88 9%
Once a week 216 21%
At least once a day 712 70%
Traveled to a developing country Yes 250 25%
No 766 75%
Voted in last election Yes 742 73%
No 274 27%
Trust in political institutions and the state 1 (no trust) 123 12.11%
2 155 15.26%
3 207 20.37%
4 276 27.17%
5 151 14.86%
6 49 4.82%
7 (complete trust) 55 5.41%
Political ideology 1 (extremely liberal) 87 8.56%
2 87 8.56%
3 112 11.02%
4 363 35.73%
5 175 17.22%
6 80 7.87%
7 (extremely conservative) 112 11.02%
Involvement in activist causes Not involved 569 56%
Involved 447 44%
Frequency of attending religious services Not sure 11 1%
Rarely 600 59%
At least once a month 405 40%
Importance of religion Not important 338 33%
Important 678 67%


Original computing environment

devtools::session_info()
## ─ Session info ─────────────────────────────────────────────────────────────────────────
##  setting  value                       
##  version  R version 4.0.3 (2020-10-10)
##  os       macOS Big Sur 10.16         
##  system   x86_64, darwin17.0          
##  ui       X11                         
##  language (EN)                        
##  collate  en_US.UTF-8                 
##  ctype    en_US.UTF-8                 
##  tz       America/New_York            
##  date     2021-04-17                  
## 
## ─ Packages ─────────────────────────────────────────────────────────────────────────────
##  ! package     * version    date       lib source                               
##  P assertthat    0.2.1      2019-03-21 [?] CRAN (R 4.0.0)                       
##  P backports     1.2.1      2020-12-09 [?] CRAN (R 4.0.2)                       
##  P broom         0.7.5      2021-02-19 [?] CRAN (R 4.0.2)                       
##  P bslib         0.2.4      2021-01-25 [?] CRAN (R 4.0.2)                       
##  P cachem        1.0.4      2021-02-13 [?] CRAN (R 4.0.2)                       
##    callr         3.6.0      2021-03-28 [1] CRAN (R 4.0.2)                       
##  P cellranger    1.1.0      2016-07-27 [?] CRAN (R 4.0.0)                       
##    cli           2.4.0      2021-04-05 [1] CRAN (R 4.0.2)                       
##  P codetools     0.2-18     2020-11-04 [?] CRAN (R 4.0.2)                       
##  P colorspace    2.0-0      2020-11-11 [?] CRAN (R 4.0.2)                       
##  P crayon        1.4.1      2021-02-08 [?] CRAN (R 4.0.2)                       
##  P data.table    1.14.0     2021-02-21 [?] CRAN (R 4.0.2)                       
##  P DBI           1.1.1      2021-01-15 [?] CRAN (R 4.0.2)                       
##  P dbplyr        2.1.0      2021-02-03 [?] CRAN (R 4.0.2)                       
##  P desc          1.3.0      2021-03-05 [?] CRAN (R 4.0.2)                       
##    devtools      2.4.0      2021-04-07 [1] CRAN (R 4.0.2)                       
##  P digest        0.6.27     2020-10-24 [?] CRAN (R 4.0.2)                       
##  P dplyr       * 1.0.5      2021-03-05 [?] CRAN (R 4.0.2)                       
##  P ellipsis      0.3.1      2020-05-15 [?] CRAN (R 4.0.0)                       
##  P evaluate      0.14       2019-05-28 [?] CRAN (R 4.0.0)                       
##  P fansi         0.4.2      2021-01-15 [?] CRAN (R 4.0.2)                       
##  P fastmap       1.1.0      2021-01-25 [?] CRAN (R 4.0.2)                       
##  P forcats     * 0.5.1      2021-01-27 [?] CRAN (R 4.0.2)                       
##  P fs            1.5.0      2020-07-31 [?] CRAN (R 4.0.2)                       
##  P generics      0.1.0      2020-10-31 [?] CRAN (R 4.0.2)                       
##  P ggplot2     * 3.3.3      2020-12-30 [?] CRAN (R 4.0.2)                       
##  P glue        * 1.4.2      2020-08-27 [?] CRAN (R 4.0.2)                       
##  P gtable        0.3.0      2019-03-25 [?] CRAN (R 4.0.0)                       
##  P haven         2.3.1      2020-06-01 [?] CRAN (R 4.0.2)                       
##  P here        * 1.0.1      2020-12-13 [?] CRAN (R 4.0.2)                       
##  P highr         0.8        2019-03-20 [?] CRAN (R 4.0.0)                       
##  P hms           1.0.0      2021-01-13 [?] CRAN (R 4.0.2)                       
##  P htmltools     0.5.1.1    2021-01-22 [?] CRAN (R 4.0.2)                       
##  P httr          1.4.2      2020-07-20 [?] CRAN (R 4.0.2)                       
##  P igraph        1.2.6      2020-10-06 [?] CRAN (R 4.0.2)                       
##  P janitor     * 2.1.0      2021-01-05 [?] CRAN (R 4.0.2)                       
##  P jquerylib     0.1.3      2020-12-17 [?] CRAN (R 4.0.2)                       
##  P jsonlite      1.7.2      2020-12-09 [?] CRAN (R 4.0.2)                       
##  P kableExtra  * 1.3.4.9000 2021-04-17 [?] Github (haozhu233/kableExtra@a6af5c0)
##  P knitr         1.31       2021-01-27 [?] CRAN (R 4.0.2)                       
##  P lifecycle     1.0.0      2021-02-15 [?] CRAN (R 4.0.2)                       
##  P lubridate     1.7.10     2021-02-26 [?] CRAN (R 4.0.2)                       
##  P magrittr      2.0.1      2020-11-17 [?] CRAN (R 4.0.2)                       
##  P memoise       2.0.0      2021-01-26 [?] CRAN (R 4.0.2)                       
##  P modelr        0.1.8      2020-05-19 [?] CRAN (R 4.0.2)                       
##  P munsell       0.5.0      2018-06-12 [?] CRAN (R 4.0.0)                       
##  P pillar        1.5.1      2021-03-05 [?] CRAN (R 4.0.2)                       
##  P pkgbuild      1.2.0      2020-12-15 [?] CRAN (R 4.0.2)                       
##  P pkgconfig     2.0.3      2019-09-22 [?] CRAN (R 4.0.0)                       
##    pkgload       1.2.1      2021-04-06 [1] CRAN (R 4.0.2)                       
##  P prettyunits   1.1.1      2020-01-24 [?] CRAN (R 4.0.0)                       
##  P processx      3.5.1      2021-04-04 [?] CRAN (R 4.0.2)                       
##  P ps            1.6.0      2021-02-28 [?] CRAN (R 4.0.2)                       
##  P purrr       * 0.3.4      2020-04-17 [?] CRAN (R 4.0.0)                       
##  P R6            2.5.0      2020-10-28 [?] CRAN (R 4.0.2)                       
##  P Rcpp          1.0.6      2021-01-15 [?] CRAN (R 4.0.2)                       
##  P readr       * 1.4.0      2020-10-05 [?] CRAN (R 4.0.2)                       
##  P readxl        1.3.1      2019-03-13 [?] CRAN (R 4.0.0)                       
##    remotes       2.3.0      2021-04-01 [1] CRAN (R 4.0.2)                       
##    renv          0.13.0     2021-02-24 [1] CRAN (R 4.0.2)                       
##  P reprex        1.0.0      2021-01-27 [?] CRAN (R 4.0.2)                       
##  P rlang         0.4.10     2020-12-30 [?] CRAN (R 4.0.2)                       
##  P rmarkdown     2.7        2021-02-19 [?] CRAN (R 4.0.2)                       
##  P rprojroot     2.0.2      2020-11-15 [?] CRAN (R 4.0.2)                       
##  P rstudioapi    0.13       2020-11-12 [?] CRAN (R 4.0.2)                       
##  P rvest         1.0.0      2021-03-09 [?] CRAN (R 4.0.2)                       
##  P sass          0.3.1      2021-01-24 [?] CRAN (R 4.0.2)                       
##  P scales      * 1.1.1      2020-05-11 [?] CRAN (R 4.0.0)                       
##  P sessioninfo   1.1.1      2018-11-05 [?] CRAN (R 4.0.0)                       
##  P snakecase     0.11.0     2019-05-25 [?] CRAN (R 4.0.0)                       
##  P stringi       1.5.3      2020-09-09 [?] CRAN (R 4.0.2)                       
##  P stringr     * 1.4.0      2019-02-10 [?] CRAN (R 4.0.0)                       
##  P svglite       2.0.0      2021-02-20 [?] CRAN (R 4.0.2)                       
##  P systemfonts   1.0.1      2021-02-09 [?] CRAN (R 4.0.2)                       
##  P targets     * 0.2.0      2021-02-27 [?] CRAN (R 4.0.2)                       
##  P testthat      3.0.2      2021-02-14 [?] CRAN (R 4.0.2)                       
##  P tibble      * 3.1.0      2021-02-25 [?] CRAN (R 4.0.2)                       
##  P tidyr       * 1.1.3      2021-03-03 [?] CRAN (R 4.0.2)                       
##  P tidyselect    1.1.0      2020-05-11 [?] CRAN (R 4.0.0)                       
##  P tidyverse   * 1.3.0      2019-11-21 [?] CRAN (R 4.0.0)                       
##  P usethis       2.0.1      2021-02-10 [?] CRAN (R 4.0.2)                       
##  P utf8          1.1.4      2018-05-24 [?] CRAN (R 4.0.0)                       
##  P vctrs         0.3.7      2021-03-29 [?] CRAN (R 4.0.2)                       
##  P viridisLite   0.4.0      2021-04-13 [?] CRAN (R 4.0.2)                       
##  P webshot       0.5.2      2019-11-22 [?] CRAN (R 4.0.0)                       
##  P withr         2.4.1      2021-01-26 [?] CRAN (R 4.0.2)                       
##  P xfun          0.22       2021-03-11 [?] CRAN (R 4.0.2)                       
##  P xml2          1.3.2      2020-04-23 [?] CRAN (R 4.0.0)                       
##  P yaml          2.2.1      2020-02-01 [?] CRAN (R 4.0.0)                       
## 
## [1] /Users/andrew/Dropbox (Personal)/Research collaboration/Global policy special issue/renv/library/R-4.0/x86_64-apple-darwin17.0
## [2] /private/var/folders/4d/ynkkj1nj0yj0lt91mkw2mq100000gn/T/Rtmpk1xlHm/renv-system-library
## 
##  P ── Loaded and on-disk path mismatch.
writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
## # http://dirk.eddelbuettel.com/blog/2017/11/27/#011_faster_package_installation_one
## VER=
## CCACHE=ccache
## CC=$(CCACHE) gcc$(VER)
## CXX=$(CCACHE) g++$(VER)
## CXX11=$(CCACHE) g++$(VER)
## CXX14=$(CCACHE) g++$(VER)
## FC=$(CCACHE) gfortran$(VER)
## F77=$(CCACHE) gfortran$(VER)
## 
## CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
LS0tCnRpdGxlOiAiVGFibGVzIgphdXRob3I6ICJTdXBhcm5hIENoYXVkaHJ5LCBNYXJjIERvdHNvbiwgYW5kIEFuZHJldyBIZWlzcyIKZGF0ZTogIkxhc3QgcnVuOiBgciBmb3JtYXQoU3lzLnRpbWUoKSwgJyVGJylgIgpvdXRwdXQ6IAogIGh0bWxfZG9jdW1lbnQ6CiAgICBjb2RlX2ZvbGRpbmc6IGhpZGUKZWRpdG9yX29wdGlvbnM6IAogIGNodW5rX291dHB1dF90eXBlOiBjb25zb2xlCi0tLQoKYGBge3Igc2V0dXAsIGluY2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