Title: | Enrich and Analyze Sovereign-Level Economic Data |
Version: | 0.1.0 |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 4.1) |
Imports: | cli, curl, dplyr (≥ 1.0.0), rlang, wbwdi, econid, imfweo |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
URL: | https://github.com/tidy-intelligence/r-econtools, https://tidy-intelligence.github.io/r-econtools/ |
BugReports: | https://github.com/tidy-intelligence/r-econtools/issues |
NeedsCompilation: | no |
Packaged: | 2025-08-31 14:39:11 UTC; krise |
Author: | Christoph Scheuch |
Maintainer: | Christoph Scheuch <christoph@tidy-intelligence.com> |
Repository: | CRAN |
Date/Publication: | 2025-09-05 11:40:13 UTC |
econtools: Tools to Analyze Economic Data
Description
A collection of tools to facilitate the analysis of economic data.
Author(s)
Maintainer: Christoph Scheuch christoph@tidy-intelligence.com (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/tidy-intelligence/r-econtools/issues
Add GDP to Country Data
Description
Add GDP to Country Data
Usage
add_gdp_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "gdp",
usd = TRUE
)
Arguments
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". |
Value
A data frame with an additional column containing GDP data.
Examples
# 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
Description
Add Government Expenditure to Country Data
Usage
add_gov_exp_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "gov_exp"
)
Arguments
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". |
Value
A data frame with an additional column containing government expenditure data.
Examples
# 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 as Share of GDP to Country Data
Description
Add Government Expenditure as Share of GDP to Country Data
Usage
add_gov_exp_share_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "gov_exp_share"
)
Arguments
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". |
Value
A data frame with an additional column containing government expenditure as share of GDP data.
Examples
# Add government expenditure share of GDP
df <- data.frame(country = c("USA", "JPN", "AUS"))
result <- add_gov_exp_share_column(df, id_column = "country")
# With specific years
df <- data.frame(country = c("USA", "JPN"), year = c(2015, 2020))
result <- add_gov_exp_share_column(
df, id_column = "country", date_column = "year"
)
Add Income Levels to Country Data
Description
Add Income Levels to Country Data
Usage
add_income_level_column(
df,
id_column,
id_type = "iso3_code",
target_column = "income_level"
)
Arguments
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". |
Value
A data frame with a additional columns containing the income level ID and name.
Examples
# 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
Description
Add ISO-3 Codes to Country Data
Usage
add_iso3_codes_column(df, id_column, target_column = "iso3_code")
Arguments
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". |
Value
A data frame with an additional column containing the ISO-3 code.
Examples
# 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
Description
Add Population Column to Country Data
Usage
add_population_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "population"
)
Arguments
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". |
Value
A data frame with an additional column containing population data.
Examples
# 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
Description
Add Population Density Column to Country Data
Usage
add_population_density_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "population_density"
)
Arguments
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". |
Value
A data frame with an additional column containing population density data.
Examples
# 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 Share Column to Country Data
Description
Add Population Share Column to Country Data
Usage
add_population_share_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
value_column = "value",
target_column = "population_share"
)
Arguments
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. |
value_column |
Name of the column containing the value to divided by population. |
target_column |
Name of the output column. Defaults to "population_share". |
Value
A data frame with an additional column containing a new column with a value divided by population.
Examples
# Compute value as a share of population
df <- data.frame(country = c("USA", "CAN"), value = c(1000, 2000))
result <- add_population_share_column(
df, id_column = "country", value_column = "value"
)
# With year-specific values
df <- data.frame(
country = c("USA", "CAN"),
year = c(2019, 2020),
value = c(1500, 1800)
)
result <- add_population_share_column(
df, id_column = "country", date_column = "year"
)
Add Poverty Ratio Column to Country Data
Description
Add Poverty Ratio Column to Country Data
Usage
add_poverty_ratio_column(
df,
id_column,
id_type = "iso3_code",
date_column = NULL,
target_column = "poverty_ratio"
)
Arguments
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". |
Value
A data frame with an additional column containing poverty ratio data.
Examples
# 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
Description
Add Short Names to Country Data
Usage
add_short_names_column(df, id_column, target_column = "name_short")
Arguments
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". |
Value
A data frame with an additional column containing the short names.
Examples
# Add short names using ISO3 codes
df <- data.frame(country = c("USA", "FRA", "JPN"))
result <- add_short_names_column(df, id_column = "country")