Learn R Programming

idbr (version 0.1.2)

idb5: Retrieve data from the five-year-age-group IDB dataset.

Description

Retrieve data from the five-year-age-group IDB dataset.

Usage

idb5(country, year, variables = NULL, concept = NULL,
  country_name = FALSE, api_key = NULL)

Arguments

country
A two-character FIPS code, or a vector of FIPS codes, of the countries for which you'd like to retrieve data.
year
A year, or a vector of years, for which you'd like to retrieve data.
variables
A vector of variables. Use idb_variables() for a full list.
concept
A concept for which you'd like to retrieve data. Use idb_concepts() for a list of options.
country_name
If TRUE, returns a column with the long country name along with the FIPS code.
api_key
The user's Census API key. Can be supplied here or set globally in an idbr session with idb_api_key(api_key).

Value

  • A data frame with the requested data.

See Also

http://api.census.gov/data/timeseries/idb/5year.html

Examples

Run this code
# World map of infant mortality rates by country for 2016 with plotly

library(idbr)
library(plotly)
library(viridis)

idb_api_key('Your API key goes here')

df <- idb5(country = 'all', year = 2016, variable = 'IMR', country_name = TRUE)

plot_ly(df, z = IMR, text = NAME, locations = NAME, locationmode = 'country names',
        type = 'choropleth', colors = viridis(99), hoverinfo = 'text+z') %>%
  layout(title = 'Infant mortality rate (per 1000 live births), 2016',
         geo = list(projection = list(type = 'robinson')))

Run the code above in your browser using DataLab