Title: | Easily Convert GDP Data |
---|---|
Description: | Convert GDP time series data from one unit to another. All common GDP units are included, i.e. current and constant local currency units, US$ via market exchange rates and international dollars via purchasing power parities. |
Authors: | Johannes Koch [aut, cre] |
Maintainer: | Johannes Koch <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.4.1 |
Built: | 2024-12-22 05:49:37 UTC |
Source: | https://github.com/pik-piam/GDPuc |
convertGDP() converts GDP time series data from one unit to another, using GDP deflators, market exchange rates (MERs) and purchasing power parity conversion factors (PPPs).
convertGDP( gdp, unit_in, unit_out, source = "wb_wdi", use_USA_cf_for_all = FALSE, with_regions = NULL, replace_NAs = NULL, verbose = getOption("GDPuc.verbose", default = FALSE), return_cfs = FALSE ) convertCPI(...) convertSingle(x, iso3c, year = NULL, unit_in, unit_out, ...) toolConvertGDP( gdp, unit_in, unit_out, source = "wb_wdi", use_USA_cf_for_all = FALSE, with_regions = NULL, replace_NAs = NULL, verbose = getOption("GDPuc.verbose", default = FALSE), return_cfs = FALSE ) toolConvertSingle(x, iso3c, year = NULL, unit_in, unit_out, ...) toolConvertCPI(...)
convertGDP( gdp, unit_in, unit_out, source = "wb_wdi", use_USA_cf_for_all = FALSE, with_regions = NULL, replace_NAs = NULL, verbose = getOption("GDPuc.verbose", default = FALSE), return_cfs = FALSE ) convertCPI(...) convertSingle(x, iso3c, year = NULL, unit_in, unit_out, ...) toolConvertGDP( gdp, unit_in, unit_out, source = "wb_wdi", use_USA_cf_for_all = FALSE, with_regions = NULL, replace_NAs = NULL, verbose = getOption("GDPuc.verbose", default = FALSE), return_cfs = FALSE ) toolConvertSingle(x, iso3c, year = NULL, unit_in, unit_out, ...) toolConvertCPI(...)
gdp |
A tibble, data frame or magpie object, the latter of which requires the magclass package to be installed. The data-frame needs to have at least 2 columns, in some cases 3:
|
unit_in |
A string with the incoming GDP unit, one of:
where YYYY should be replaced with a year e.g. "2010" or "2017". |
unit_out |
A string with the outgoing GDP unit, one of:
where YYYY should be replaced with a year e.g. "2010" or "2017". |
source |
A string referring to a package internal data frame containing the conversion factors, or a data-frame that exists in the calling environment. Use print_source_info() to learn about the available sources. |
use_USA_cf_for_all |
TRUE or FALSE (default). If TRUE, then the USA conversion factors are used for all countries. |
with_regions |
NULL by default, meaning no regional codons are recognized. To convert regional data, a "country to region mapping" must be passed to the function. Any regions will then be disaggregated according to the region mapping and weighed by the GDP share of countries in that region in the year of the unit (only constant units are compatible with with_regions not equal NULL), converted on a country level, and re-aggregated before being returned. Can be set to one of the following:
|
replace_NAs |
NULL by default, meaning no NA replacement. Can be set to one of the following:
Can also be a vector with "linear" as first element, e.g. c("linear", 0) or c("linear", "no_conversion"), in which case, the operations are done in sequence. |
verbose |
TRUE or FALSE. A flag to turn verbosity on or off. Be default it is equal to the GDPuc.verbose option, which is FALSE if not set to TRUE by the user. |
return_cfs |
TRUE or FALSE. Set to TRUE to additionally return a tibble with the conversion factors used. In that case a list is returned with the converted GDP under "result", and the conversion factors used under "cfs". |
... |
Arguments passed on to |
x |
Number to convert |
iso3c |
Country code |
year |
NULL, or year of value. Only plays a role when converting from or to current currencies. |
When providing a custom source to the function, a certain format is required. The source object must be a data frame or tibble with at least the following columns:
a character column named "iso3c" with iso3c (wikipedia) country codes,
a numeric column named "year" with years,
a numeric column named "GDP deflator" with values of the GDP deflator divided by 100 (so that in the base year the GDP deflator is equal to 1, not 100). The base year of the deflator can be any year, and can be country-specific.
a numeric column named "MER (LCU per US$)" with MER values,
a numeric column named "PPP conversion factor, GDP (LCU per international $)" wit PPP exchange rate values.
The gdp argument, with the values in the "value" column, converted to unit_out. If the argument return_cfs is TRUE, then a list is returned with the converted GDP under "result", and the conversion factors used under "cfs".
convertCPI()
: Short cut for convertGDP(..., source = "wb_wdi_cpi")
convertSingle()
: Convert a single value, while specifying iso3c code and year. Simpler than creating a
single row tibble.
toolConvertGDP()
: Madrat wrapper around convertGDP()
toolConvertSingle()
: Madrat wrapper around convertSingle()
toolConvertCPI()
: Madrat wrapper around convertCPI(...)
The countrycode package to convert country codes.
my_tbble <- tibble::tibble(iso3c = "FRA", year = 2013, value = 100) convertGDP(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP") # Convert using the CPI as deflator. convertGDP(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP", source = "wb_wdi_cpi") # Or using the shortcut `convertCPI()` convertCPI(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP") # Convert a single value quickly convertSingle(x = 100, iso3c = "FRA", year = 2013, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP")
my_tbble <- tibble::tibble(iso3c = "FRA", year = 2013, value = 100) convertGDP(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP") # Convert using the CPI as deflator. convertGDP(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP", source = "wb_wdi_cpi") # Or using the shortcut `convertCPI()` convertCPI(gdp = my_tbble, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP") # Convert a single value quickly convertSingle(x = 100, iso3c = "FRA", year = 2013, unit_in = "current LCU", unit_out = "constant 2015 Int$PPP")
Print detailed information on conversion factor sources to the screen. Information includes the name, origin, date, html-link and an associated note. Calling the function without any argument will print information on all available sources.
print_source_info(source)
print_source_info(source)
source |
Empty, or the name of one of the internal sources:
|
No return value, called for side effects.
print_source_info()
print_source_info()