Creating a cost conversion table using an example of sponsorship packages.
# 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"))
# summarizing GDP (PPP-adjusted) per income_group
gdp_ppp_summary <-
gdp_ppp_full %>%
na.omit(PPP_GDPCap) %>%
group_by(income_group) %>%
summarize(
avg_GDP = mean(PPP_GDPCap),
sd_GDP = sd(PPP_GDPCap)) %>%
# creating conversion factor
mutate(norm_avg_GDP = avg_GDP/max(avg_GDP)) %>%
arrange(desc(avg_GDP)) %>%
mutate_if(is.numeric, round, 2)
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 |
# adding sponsorship level example
cost_conversion <-
gdp_ppp_summary %>%
select(-(avg_GDP:sd_GDP)) %>%
rename("conversion_factor"="norm_avg_GDP") %>%
mutate(platinum = 15000,
gold = 10000,
silver = 7500,
bronze = 3000,
network = 1000) %>%
mutate(platinum = platinum*conversion_factor, # adjusts by the conversion factor
gold = gold*conversion_factor,
silver = silver*conversion_factor,
bronze = bronze*conversion_factor,
network = network*conversion_factor)
To create sponsorship packages, income_group
s “Low income” and “Lower middle income” were combined into one category: “Lower income”
# dropping the "Low income" category and reclassifying "Lower middle income"
# to create sponsorship packages
cost_conversion_trim <-
cost_conversion %>%
filter(income_group != "Low income") %>%
mutate(income_group = fct_recode(
income_group,
"Lower income" = "Lower middle income")
)
Sponsorship Packages | ||||||
---|---|---|---|---|---|---|
Cost Conversions by Global Income Group (US$) | ||||||
Global Income Group | Conversion Factor | Platinum | Gold | Silver | Bronze | Network |
High income | 1.00 | $15,000 | $10,000 | $7,500 | $3,000 | $1,000 |
Upper middle income | 0.34 | $5,100 | $3,400 | $2,550 | $1,020 | $340 |
Lower income | 0.14 | $2,100 | $1,400 | $1,050 | $420 | $140 |
Prices listed are in USD
# recoding "Low income" and "Lower middle income" as "Lower income" to create sponsorship packages
classification_trim %>%
mutate(income_group = fct_recode(
income_group,
"Lower income" = "Low income",
"Lower income" = "Lower middle income")) %>%
left_join(cost_conversion_trim) %>%
mutate_at(vars(conversion_factor:network), factor) %>%
DT::datatable(
filter = 'top',
options = list(
pageLength = 5),
colnames = c('Country/Economy', 'Economy Code', 'Region',
'Global Income Group', 'Conversion Factor',
'Platinum', 'Gold', 'Silver', 'Bronze', 'Network')
) %>%
DT::formatCurrency(
c("platinum", "gold", "silver", "bronze", "network"),
currency = "$",
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 ...".