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.
The package ships with a data frame with id and indicator names
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 and a measure of female educaction for all years and all countries, and plot these against each other:
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)")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.