convertGDP {GDPuc} | R Documentation |
Convert GDP data
Description
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).
Usage
convertGDP(
gdp,
unit_in,
unit_out,
source = "wb_wdi",
use_USA_deflator_for_all = FALSE,
with_regions = NULL,
replace_NAs = NULL,
verbose = getOption("GDPuc.verbose", default = FALSE),
return_cfs = FALSE
)
convertCPI(...)
convertSingle(x, iso3c, year = NULL, ...)
Arguments
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_deflator_for_all |
TRUE or FALSE (default). If TRUE, then only the USA deflator is used to adjust for inflation, regardless of the country codes provided. This is a very specific deviation from the correct conversion process, which nevertheless is often used in the integrated assessment community. Use carefully! |
with_regions |
NULL or a data-frame. The data-frame should be "country to region mapping": one column named "iso3c" with iso3c country codes, and one column named "region" with region codes to which the countries belong. Any regions in the gdp object 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, converted on a country level, and re-aggregated before being returned. |
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. |
Details
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.
Value
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".
Functions
-
convertCPI()
: Short cut forconvertGDP(..., source = "wb_wdi_cpi")
-
convertSingle()
: Convert a single value, while specifying iso3c code and year. Simpler than creating a single row tibble.
See Also
The countrycode package to convert country codes.
Examples
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")