-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
202 lines (143 loc) · 4.26 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
output: github_document
---
<!-- 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%"
)
```
# idswb <a href="https://teal-insights.github.io/idswb/"><img src="man/figures/logo.png" align="right" height="139" alt="idswb website" /></a>
<!-- badges: start -->
[![R-CMD-check](https://github.com/Teal-Insights/idswb/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Teal-Insights/idswb/actions/workflows/R-CMD-check.yaml)
[![LifeCycle](https://img.shields.io/badge/lifecycle-experimental-orange)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Test coverage](https://github.com/Teal-Insights/idswb/actions/workflows/test-coverage.yaml/badge.svg)](https://github.com/Teal-Insights/idswb/actions/workflows/test-coverage.yaml)
[![License: CC0](https://img.shields.io/badge/License-CC0-lightgrey.svg)](https://choosealicense.com/licenses/cc0-1.0/)
[![Website](https://github.com/Teal-Insights/idswb/actions/workflows/pkgdown.yaml/badge.svg)](https://github.com/Teal-Insights/idswb/actions/workflows/pkgdown.yaml)
<!-- badges: end -->
```{r}
```
`idswb` is primarily a data package enabling an efficient method for working with [International Debt Statistics from World Bank](https://www.worldbank.org/en/programs/debt-statistics/ids) in R.
## Installation
You can install the development version of idswb from [GitHub](https://github.com/) with:
``` r
# setting options
options(timeout = 600, scipen = 999)
# install.packages("devtools")
devtools::install_github("Teal-Insights/idswb")
```
This package will likely never be published on [CRAN](https://cran.r-project.org/) because the data file sizes are too big.
## Example
This is a basic example which shows you how to solve a common problem:
```{r warning=FALSE, message=FALSE}
library(idswb)
library(knitr)
library(tidyverse)
```
```{r}
```
## Overview of available datasets in idswb package
```{r}
```
* unique_counterpart_area: information on counterparts (creditors)
```{r}
unique_counterpart_area %>% head()
```
```{r}
```
* unique_country: information on debtors
```{r}
unique_country %>% head()
```
```{r}
```
* unique_series: information on series
```{r}
unique_series %>% head()
```
```{r}
```
* unique_time: information on years
```{r}
unique_time %>% head()
```
```{r}
```
## creating an etl object
We create an ETL object by specifying a string that defines the object's class, and use the package `idswb` to gain access to the relevant data.
```{r}
# ceating an object
# idswb_ob <-etl("idswb", dir = getwd())
```
```{r}
```
## Extract
The first step here is to acquire data
```{r}
# idswb_ob %>% etl_extract()
```
```{r}
```
## Transform
This data might require conversion from its original format into files that are appropriate for SQL import, typically in CSV format.
```{r}
# idswb_ob %>% etl_transform()
```
```{r}
```
## Load
Fill the SQL database with the processed data.
```{r}
# idswb_ob %>% etl_load()
```
```{r}
```
We can still perform the steps above at once
```{r message = FALSE, warning=FALSE}
# ceating an object
idswb_ob <-etl("idswb", dir = getwd())
idswb_ob %>%
# extract
etl_extract() %>%
# transform
etl_transform() %>%
# load
etl_load()
```
```{r}
```
## Using etl_create method
```{r}
# idswb_ob %>% etl_create()
```
```{r}
```
## Querying data
We can now query debt of a given country that it owes to both China and the World as follows
`Query 1:`
```{r}
# input specifications
series <- c("DT.DOD.BLAT.CD","DT.DOD.PBND.CD",'DT.DOD.MLAT.CD',"DT.DOD.PROP.CD","DT.DOD.PCBK.CD","DT.DOD.DPPG.CD")
debtor <- "Kenya"
creditor <- c("China","World")
# Querying data
ids_query_data(etl_object = idswb_ob, debtor = debtor, creditor = creditor, series = series) %>%
dplyr::filter(year == "2022")
```
```{r}
```
`Query 2:`
```{r}
# input specifications
series <- c("DT.DOD.BLAT.CD","DT.DOD.PBND.CD",'DT.DOD.MLAT.CD',"DT.DOD.PROP.CD","DT.DOD.PCBK.CD","DT.DOD.DPPG.CD")
debtor <- "Nigeria"
creditor <- c("China","World")
# Querying data
ids_query_data(etl_object = idswb_ob, debtor = debtor, creditor = creditor, series = series) %>%
dplyr::filter(year == "2022")
```
```{r}
```