https://github.com/guyabel/wcde
Package to download data from the Wittgenstein Centre Human Capital Data Explorer into R
https://github.com/guyabel/wcde
demography demograpic-data population-data r rstats rstats-package
Last synced: about 1 year ago
JSON representation
Package to download data from the Wittgenstein Centre Human Capital Data Explorer into R
- Host: GitHub
- URL: https://github.com/guyabel/wcde
- Owner: guyabel
- Created: 2020-11-07T16:30:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T02:27:11.000Z (about 1 year ago)
- Last Synced: 2025-04-05T00:37:01.804Z (about 1 year ago)
- Topics: demography, demograpic-data, population-data, r, rstats, rstats-package
- Language: R
- Homepage: https://guyabel.github.io/wcde/
- Size: 367 MB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: docs/CONTRIBUTING.html
- Code of conduct: docs/CODE_OF_CONDUCT.html
- Support: docs/SUPPORT.html
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[](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)
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')
```
