| Title: | Enrich and Analyze Sovereign-Level Economic Data |
|---|---|
| Description: | Provides a consistent set of functions for enriching and analyzing sovereign-level economic data. Economists, data scientists, and financial professionals can use the package to add standardized identifiers, demographic and macroeconomic indicators, and derived metrics such as gross domestic product per capita or government expenditure shares. |
| Authors: | Christoph Scheuch [aut, cre, cph] (ORCID: <https://orcid.org/0009-0004-0423-6819>) |
| Maintainer: | Christoph Scheuch <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1.9000 |
| Built: | 2026-05-11 09:36:58 UTC |
| Source: | https://github.com/tidy-intelligence/r-econtools |
Add GDP to Country Data
add_gdp_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "gdp", usd = TRUE )add_gdp_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "gdp", usd = TRUE )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
date_column |
Optional. Name of the column containing dates for time-specific data. |
target_column |
Name of the output column. Defaults to "gdp". |
usd |
Logical. Indicates whether GDP should be in USD or local currency. Defaults to "TRUE". |
A data frame with an additional column containing GDP data.
# Add most recent GDP values df <- data.frame(country = c("USA", "CHN", "DEU")) result <- add_gdp_column(df, id_column = "country") # Add year-specific GDP values df <- data.frame(country = c("USA", "CHN"), year = c(2019, 2020)) result <- add_gdp_column(df, id_column = "country", date_column = "year")# Add most recent GDP values df <- data.frame(country = c("USA", "CHN", "DEU")) result <- add_gdp_column(df, id_column = "country") # Add year-specific GDP values df <- data.frame(country = c("USA", "CHN"), year = c(2019, 2020)) result <- add_gdp_column(df, id_column = "country", date_column = "year")
Add Government Expenditure to Country Data
add_gov_exp_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "gov_exp" )add_gov_exp_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "gov_exp" )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
date_column |
Optional. Name of the column containing dates for time-specific data. |
target_column |
Name of the output column. Defaults to "gov_exp". |
A data frame with an additional column containing government expenditure data.
# Add government expenditure df <- data.frame(country = c("USA", "GBR", "FRA")) result <- add_gov_exp_column(df, id_column = "country") # With years df <- data.frame(country = c("USA", "GBR"), year = c(2010, 2020)) result <- add_gov_exp_column(df, id_column = "country", date_column = "year")# Add government expenditure df <- data.frame(country = c("USA", "GBR", "FRA")) result <- add_gov_exp_column(df, id_column = "country") # With years df <- data.frame(country = c("USA", "GBR"), year = c(2010, 2020)) result <- add_gov_exp_column(df, id_column = "country", date_column = "year")
Add Income Levels to Country Data
add_income_level_column( df, id_column, id_type = "iso3_code", target_column = "income_level" )add_income_level_column( df, id_column, id_type = "iso3_code", target_column = "income_level" )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
target_column |
Name of the output column. Defaults to "income_level". |
A data frame with a additional columns containing the income level ID and name.
# Add income levels using ISO3 codes df <- data.frame(country = c("USA", "NGA", "IND")) result <- add_income_level_column(df, id_column = "country")# Add income levels using ISO3 codes df <- data.frame(country = c("USA", "NGA", "IND")) result <- add_income_level_column(df, id_column = "country")
Add ISO-3 Codes to Country Data
add_iso3_codes_column(df, id_column, target_column = "iso3_code")add_iso3_codes_column(df, id_column, target_column = "iso3_code")
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
target_column |
Name of the output column. Defaults to "iso3_code". |
A data frame with an additional column containing the ISO-3 code.
# Convert country names to ISO3 codes df <- data.frame(name = c("United States", "Canada", "Mexico")) result <- add_iso3_codes_column(df, id_column = "name")# Convert country names to ISO3 codes df <- data.frame(name = c("United States", "Canada", "Mexico")) result <- add_iso3_codes_column(df, id_column = "name")
Add Population Column to Country Data
add_population_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "population" )add_population_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "population" )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
date_column |
Optional. Name of the column containing dates for time-specific data. |
target_column |
Name of the output column. Defaults to "population". |
A data frame with an additional column containing population data.
# Add population data using ISO3 codes df <- data.frame(country = c("USA", "CAN", "MEX")) result <- add_population_column(df, id_column = "country") # Add population data with specific dates df <- data.frame(country = c("USA", "CAN"), year = c(2019, 2020)) result <- add_population_column( df, id_column = "country", date_column = "year" )# Add population data using ISO3 codes df <- data.frame(country = c("USA", "CAN", "MEX")) result <- add_population_column(df, id_column = "country") # Add population data with specific dates df <- data.frame(country = c("USA", "CAN"), year = c(2019, 2020)) result <- add_population_column( df, id_column = "country", date_column = "year" )
Add Population Density Column to Country Data
add_population_density_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "population_density" )add_population_density_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "population_density" )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
date_column |
Optional. Name of the column containing dates for time-specific data. |
target_column |
Name of the output column. Defaults to "population_density". |
A data frame with an additional column containing population density data.
# Add population density using ISO3 codes df <- data.frame(country = c("FRA", "DEU", "ESP")) result <- add_population_density_column(df, id_column = "country") # Add population density with year df <- data.frame(country = c("FRA", "DEU"), year = c(2015, 2020)) result <- add_population_density_column( df, id_column = "country", date_column = "year" )# Add population density using ISO3 codes df <- data.frame(country = c("FRA", "DEU", "ESP")) result <- add_population_density_column(df, id_column = "country") # Add population density with year df <- data.frame(country = c("FRA", "DEU"), year = c(2015, 2020)) result <- add_population_density_column( df, id_column = "country", date_column = "year" )
Add Poverty Ratio Column to Country Data
add_poverty_ratio_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "poverty_ratio" )add_poverty_ratio_column( df, id_column, id_type = "iso3_code", date_column = NULL, target_column = "poverty_ratio" )
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
id_type |
Type of country identifier. Defaults to "iso3_code". |
date_column |
Optional. Name of the column containing dates for time-specific data. |
target_column |
Name of the output column. Defaults to "poverty_ratio". |
A data frame with an additional column containing poverty ratio data.
# Add poverty ratio using ISO3 codes df <- data.frame(country = c("USA", "IND", "BRA")) result <- add_poverty_ratio_column(df, id_column = "country") # Add poverty ratio with specific dates df <- data.frame(country = c("USA", "IND"), year = c(2018, 2020)) result <- add_poverty_ratio_column( df, id_column = "country", date_column = "year" )# Add poverty ratio using ISO3 codes df <- data.frame(country = c("USA", "IND", "BRA")) result <- add_poverty_ratio_column(df, id_column = "country") # Add poverty ratio with specific dates df <- data.frame(country = c("USA", "IND"), year = c(2018, 2020)) result <- add_poverty_ratio_column( df, id_column = "country", date_column = "year" )
Add Short Names to Country Data
add_short_names_column(df, id_column, target_column = "name_short")add_short_names_column(df, id_column, target_column = "name_short")
df |
A data frame containing country identifiers. |
id_column |
Name of the column containing country identifiers. |
target_column |
Name of the output column. Defaults to "name_short". |
A data frame with an additional column containing the short names.
# Add short names using ISO3 codes df <- data.frame(country = c("USA", "FRA", "JPN")) result <- add_short_names_column(df, id_column = "country")# Add short names using ISO3 codes df <- data.frame(country = c("USA", "FRA", "JPN")) result <- add_short_names_column(df, id_column = "country")