-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
106 lines (76 loc) · 3.63 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
---
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%"
)
```
# wcde <a href="https://guyabel.github.io/wcde/"><img src="man/figures/logo.png" align="right" height="138"/></a>
<!-- badges: start -->
[](https://CRAN.R-project.org/package=wcde)
[](https://r-pkg.org/pkg/wcde)
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://github.com/guyabel/wcde/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
<!-- <img src='https://raw.githubusercontent.com/guyabel/wcde/main/hex/logo_transp.png' align="right" height="200" style="float:right; height:200px;"/> -->
Download data from the [Wittgenstein Centre for Demography and Human Capital Data Explorer](http://dataexplorer.wittgensteincentre.org/) into R
See the [pkgdown site](https://guyabel.github.io/wcde/) for full details.
## Installation
You can install the released version of `wcde` from [CRAN](https://CRAN.R-project.org) with:
```{r eval=FALSE}
install.packages("wcde")
```
Install the developmental version with:
```{r eval=FALSE}
library(devtools)
install_github("guyabel/wcde", ref = "main")
```
## Example
Download data based on a indicator, scenario and country code:
```{r example}
library(wcde)
# SSP2 education specific tfr for Austria
get_wcde(indicator = "etfr", country_name = "Austria")
# SSP2 education specific population sizes for Iran and Kenya
get_wcde(indicator = "pop", country_code = c(364, 404), pop_edu = "four")
# SSP1, 2 and 3 gender gaps in educational attainment (15+) for all countries
get_wcde(indicator = "ggapedu15", scenario = 1:3)
```
## Vignette
The [vignette](https://guyabel.github.io/wcde/articles/wcde.html) provides many more examples on how to use the package to download data and produce plots from the Wittgenstein Centre Human Capital Data Explorer.
```{r, echo=FALSE, eval=FALSE}
# run by hand
library(gganimate)
d <- get_wcde(indicator = "epop", country_code = 900)
g <- d %>%
edu_group_sum(n = 6) %>%
mutate(pop = ifelse(test = sex == "Male", yes = -epop, no = epop),
pop = pop/1e3,
pop_max = ifelse(sex == "Male", -max(pop), max(pop))) %>%
ggplot(mapping = aes(x = pop, y = age, fill = fct_rev(education))) +
geom_col() +
geom_vline(xintercept = 0, colour = "black") +
scale_x_continuous(labels = abs, expand = c(0, 0)) +
scale_fill_manual(values = wic_col6, name = "Education") +
facet_wrap(facets = "sex", scales = "free_x", strip.position = "bottom") +
geom_blank(mapping = aes(x = pop_max * 1.1)) +
theme(panel.spacing.x = unit(0, "pt"),
strip.placement = "outside",
strip.background = element_rect(fill = "transparent"),
strip.text.x = element_text(margin = margin( b = 0, t = 0))) +
transition_time(time = year) +
labs(x = "Population (millions)", y = "Age",
title = 'SSP2 World Population {round(frame_time)}')
animate(g, width = 15, height = 15, units = "cm", res = 200,
renderer = gifski_renderer())
anim_save(filename = "world6_ssp2.gif")
```
```{r echo=FALSE, out.height="600px", out.width="600px"}
knitr::include_graphics('https://raw.githubusercontent.com/guyabel/wcde/main/world6_ssp2.gif')
```
<!-- <img src='world6_ssp2.gif' height="600"/> -->