-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
134 lines (99 loc) · 3.67 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
output: github_document
always_allow_html: yes
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# GDPuc
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/GDPuc)](https://CRAN.R-project.org/package=GDPuc) [![check](https://github.com/pik-piam/GDPuc/actions/workflows/check.yaml/badge.svg)](https://github.com/pik-piam/GDPuc/actions/workflows/check.yaml)
[![codecov](https://codecov.io/gh/pik-piam/GDPuc/branch/main/graph/badge.svg?token=3GHXFQXARX)](https://app.codecov.io/gh/pik-piam/GDPuc)
![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)
<!-- badges: end -->
GDPuc (a.k.a. the GDP unit-converter) provides a simple function to convert GDP time-series data from one unit to another.
**To note:** The default conversion parameters are from the World Bank's World Development Indicators (WDI) database (see [link](https://databank.worldbank.org/source/world-development-indicators)). The current parameters are from **April 30th 2024**, with the next update planned for April 2026.
## Installation
```{r, eval = FALSE}
# Install from CRAN
install.packages("GDPuc")
# Or the development version from GitHub
remotes::install_github("pik-piam/GDPuc")
```
## Usage
Load the package.
```{r eval=FALSE}
library(GDPuc)
```
The main function of the package is `convertGDP`.
```{r usage1, eval=FALSE}
convertGDP(
gdp = my_gdp,
unit_in = "constant 2005 LCU",
unit_out = "constant 2017 Int$PPP"
)
```
Here, the `gdp` argument takes a tibble or a data-frame that contains, at least:
- a column with iso3c country codes, (ideally named "iso3c"),
- a column with the year, (ideally named "year"),
- a column named "value", with the gdp data.
The `unit_in` and `unit_out` arguments specify the incoming and outgoing GDP units. All common GDP units are supported, i.e.:
- current LCU
- current US$MER
- current Int$PPP
- constant YYYY LCU
- constant YYYY US$MER
- constant YYYY Int$PPP
Here "YYYY" is a placeholder for a year, e.g. "2010" or "2015", and "LCU" stands for Local Currency Unit.
For a quick conversion of a single value use `convertSingle`.
```{r usage2, eval=FALSE}
convertSingle(
x = 100,
iso3c = "FRA",
year = 2000,
unit_in = "current LCU",
unit_out = "constant 2017 Int$PPP"
)
```
## Example
```{r example1}
library(GDPuc)
my_gdp <- tibble::tibble(
iso3c = "USA",
year = 2010:2014,
value = 100:104
)
print(my_gdp)
convertGDP(
gdp = my_gdp,
unit_in = "constant 2005 LCU",
unit_out = "constant 2017 Int$PPP"
)
convertSingle(
x = 100,
iso3c = "USA",
year = 2010,
unit_in = "current LCU",
unit_out = "constant 2017 Int$PPP"
)
# When converting between constant currencies, the year of the GDP value is not important,
# and can be left out.
convertSingle(
x = 100,
iso3c = "USA",
unit_in = "constant 2005 LCU",
unit_out = "constant 2017 Int$PPP"
)
```
## Further Options
`convertGDP` has other arguments that allow you to:
- choose conversion factors (see ["Choosing conversion factors"](https://pik-piam.github.io/GDPuc/articles/source.html))
- print out information on the conversion process and/or return the conversion factors used (see ["Getting information on the conversion process"](https://pik-piam.github.io/GDPuc/articles/verbose.html))
- handle missing conversion factors (see ["Handling missing conversion factors"](https://pik-piam.github.io/GDPuc/articles/handle_NAs.html))
- convert regional GDP data (see ["Converting regional GDP data"](https://pik-piam.github.io/GDPuc/articles/with_regions.html))