knitr::opts_chunk$set( message = FALSE, warnings = FALSE, fig.path = "README-" )
The hdr
package provides a complete interface to the United Nations Development Programme Human Development Report API. This data source includes a large amount
of human development data, including all the series used to compute the
Human Development Index (HDI), as well as the HDI itself.
To get the package:
# From CRAN install.packages("hdr") # Development version library(devtools) install_github("expersso/hdr")
library(hdr) # Get a data frame with id and indicator names head(hdr_indicators) # Get the Human Development Index for Germany in 2013 hdi <- get_data(indicator = 137506, country = "DEU", year = 2013) head(hdi) # Leave a dimension as NULL (default) to get all values for that dimension # e.g. all countries and all year for a specific indicator: df <- get_data(103606) head(df) # Get the adolescent birth rate for all years and all countries br <- get_data(c(24806, 36806), year = 2010:2013) library(dplyr) library(tidyr) br <- br %>% group_by(id, iso3c) %>% summarise(mean_val = mean(value, na.rm = TRUE)) %>% spread(id, mean_val) %>% .[complete.cases(.), ] %>% setNames(c("iso3c", "fem_ed", "birth_rate")) library(ggplot2) ggplot(br, aes(x = fem_ed, y = birth_rate, label = iso3c)) + geom_text(size = 3, alpha = 0.75) + geom_smooth() + theme_light(8) + labs(y = "\nAdolescent birth rate (women aged 15-19 years)", x = "Population with at least secondary education, female/male ratio\n", title = "Relationship between female education and adolescent birth rate (2010-2013 means)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.