-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
95 lines (69 loc) · 2.51 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
---
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%"
)
```
# uisapi
<!-- badges: start -->


[](https://app.codecov.io/gh/tidy-intelligence/r-uisapi)
<!-- badges: end -->
Retrieve data from the [UNESCO Institute for Statistics (UIS) API](https://api.uis.unesco.org/api/public/documentation/).
The package is part of the [econdataverse](https://www.econdataverse.org/) family of packages aimed at helping economists and financial professionals work with sovereign-level economic data.
## Installation
You can install the development version of `uisapi` from GitHub with:
```
# install.packages("pak")
pak::pak("tidy-intelligence/r-uisapi")
```
## Usage
Load the package:
```{r}
library(uisapi)
```
To fetch indicators for specific entities, you can call:
```{r}
uis_get(
entities = c("BRA", "USA"),
indicators = c("CR.1", "CR.2"),
start_year = 2010,
end_year = 2020
)
```
You can get information about the available entities via:
```{r}
uis_get_entities()
```
The list of available indicators can be retrieved via:
```{r}
uis_get_indicators()
```
The API supports versioning and you can retrieve all versions using:
```{r}
uis_get_versions()
```
If you are only interested in the current default version, you can use the parameter `default`:
```{r}
uis_get_versions(default = TRUE)
```
The API will only return 100,000 records for each query, if more data is requested, the API call with fail with a 400 http status code. If you need more data, then UIS recommends using the [Bulk Data Download Service (BDDS)](https://databrowser.uis.unesco.org/resources/bulk). You can get a list of available files via:
```{r}
uis_bulk_files()
```
Each bulk files consists of multiple CSV files and the `uisapi` package currently does not provide automatic importers for these files. Rather, you can use base utils to download a specific file, unzip it, and read its files. For instance:
```{r eval = FALSE}
download.file(
"https://uis.unesco.org/sites/default/files/documents/bdds/092024/SDG.zip",
destfile = "SDG.zip"
)
unzip("SDG.zip")
read.csv("SDG_COUNTRY.csv")
```