Creating a cost conversion table using an example of conference fees.
# loading packages----
pkgs = c("tidyverse", "here", "glue", "gt", "DT")
pacman::p_load(char = pkgs, install = FALSE, update = FALSE)
# setting options----
knitr::opts_chunk$set(echo = TRUE, fig.retina = 3, 
                      warning=FALSE, message=FALSE)
options(scipen=999)
# importing data
gdp_ppp_full <-
  read_rds(here("data-processed",
                "economy-classification-w-GDP.Rds"))
classification_trim <-
  read_rds(here("data-processed",
                "economy-classification.Rds"))
| GDP and Conversion Factor | |||
|---|---|---|---|
| Global Income Group | Avg. GDP | St. Dev. GDP | Conversion Factor | 
| High income | $46,098 | $21,617 | 1.00 | 
| Upper middle income | $15,487 | $4,900 | 0.34 | 
| Lower middle income | $6,276 | $3,107 | 0.14 | 
| Low income | $1,740 | $809 | 0.04 | 
# cost conversion
cost_conversion_early_bird <-
  gdp_ppp_summary %>%
  select(-(avg_GDP:sd_GDP)) %>%
  rename("conversion_factor"="norm_avg_GDP") %>%
  mutate(industry = 75,
         academia = 50,
         student = 25) %>%
  # adjusts by the conversion factor
  mutate(industry = industry*conversion_factor, 
         academia = academia*conversion_factor,
         student = student*conversion_factor) %>%
  mutate(industry = ifelse(income_group == "Low income",
                           0, industry),
         academia = ifelse(income_group == "Low income",
                           0, academia),
         student = ifelse(income_group == "Low income",
                           0, student))
| Early Bird Conference Fees | ||||
|---|---|---|---|---|
| Cost Conversions by Global Income Group (US$) | ||||
| Global Income Group | Conversion Factor | Industry | Academia | Student | 
| High income | 1.00 | $75 | $50 | $25 | 
| Upper middle income | 0.34 | $26 | $17 | $8 | 
| Lower middle income | 0.14 | $11 | $7 | $4 | 
| Low income | 0.04 | $0 | $0 | $0 | 
# cost conversion
cost_conversion_regular <-
  gdp_ppp_summary %>%
  select(-(avg_GDP:sd_GDP)) %>%
  rename("conversion_factor"="norm_avg_GDP") %>%
  mutate(industry = 100,
         academia = 75,
         student = 50) %>%
  # adjusts by the conversion factor
  mutate(industry = industry*conversion_factor, 
         academia = academia*conversion_factor,
         student = student*conversion_factor) %>%
  mutate(industry = ifelse(income_group == "Low income",
                           0, industry),
         academia = ifelse(income_group == "Low income",
                           0, academia),
         student = ifelse(income_group == "Low income",
                           0, student))
| Regular Conference Fees | ||||
|---|---|---|---|---|
| Cost Conversions by Global Income Group (US$) | ||||
| Global Income Group | Conversion Factor | Industry | Academia | Student | 
| High income | 1.00 | $100 | $75 | $50 | 
| Upper middle income | 0.34 | $34 | $26 | $17 | 
| Lower middle income | 0.14 | $14 | $11 | $7 | 
| Low income | 0.04 | $0 | $0 | $0 | 
Prices listed are in USD
# creating DT table
classification_trim %>%
  left_join(cost_conversion_early_bird) %>%
  mutate_at(vars(conversion_factor:student), factor) %>%
  select(-conversion_factor, -economy_code) %>%
  DT::datatable(
    filter = 'top',
    options = list(
      pageLength = 5),
    colnames = c('Country/Economy', 'Region', 
                 'Global Income Group',
                 'Industry', 'Academia', 'Student')) %>%
  DT::formatCurrency(c("industry", "academia", "student"),
                     digits = 0)
# creating DT table
classification_trim %>%
  left_join(cost_conversion_regular) %>%
  mutate_at(vars(conversion_factor:student), factor) %>%
  select(-conversion_factor, -economy_code) %>%
  DT::datatable(
    filter = 'top',
    options = list(
      pageLength = 5),
    colnames = c('Country/Economy', 'Region', 
                 'Global Income Group',
                 'Industry', 'Academia', 'Student')) %>%
  DT::formatCurrency(c("industry", "academia", "student"),
                     digits = 0)
If you see mistakes or want to suggest changes, please create an issue on the source repository.
Text and figures are licensed under Creative Commons Attribution CC BY-SA 4.0. Source code is available at https://github.com/spcanelon/useR2021-cost-conversion-tool, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".