Travis-CI Build Status AppVeyor Build Status

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

About

The package saipeAPI provides an R client for Census Bureau's API for Small Area Income and Poverty Estimates (SAIPE). Here is a short introduction for the SAIPE program from Census:

The Small Area Income and Poverty Estimates (SAIPE) program produces single-year estimates of median household income and poverty for states and all counties, as well as population and poverty estimates for school districts. Since SAIPE estimates combine ACS data with administrative and other data, SAIPE estimates generally have lower variance than ACS estimates but are released later because they incorporate ACS data in the models. For counties and school districts, particularly those with populations below 65,000, the SAIPE program provides the most accurate subnational estimates of poverty. For counties, SAIPE generally provides the best single-year estimates of median household income.

Installation

# install.packages("remotes")
remotes::install_github("jjchern/saipeAPI@v0.0.3")

Features

saipeAPI have three functions that return SAIPE data at different geographic level:

saipeAPI::saipe_us()
saipeAPI::saipe_state()
saipeAPI::saipe_county()

Available Geographies

Census's SAIPE has four levels of income and poverty estimates: us, state, county, and school district.

Available Years (Source)

Available Variables (Source)

library(dplyr, warn.conflicts = FALSE)
saipeAPI::saipe_vars %>%
        select(Name, Label) %>% 
        knitr::kable()

Usage

Obtain an API key from the U.S. Census Bureau at http://api.census.gov/data/key_signup.html. After that, set your API key with the function saipeAPI::set_api_key(), and then start calling the data retrieval functions.

You can also save your API key in the .Renviron file for future usage. First, open the .Renviron file by

# install.packages("usethis")
usethis::edit_r_environ()

Save your key in the file in the format of

saipe_key='<Your API Key Here>'

Reload the .Renviron file and check if the key can be assessed:

readRenviron("~/.Renviron")
Sys.getenv("saipe_key")

National level estimates of median household income and poverty rate in 2010--2017

# saipe::set_api_key("<Your API Key Here>")
saipeAPI::saipe_us(year = 2010:2017, var = c("NAME", "SAEMHI_PT", "SAEPOVRTALL_PT"))

State-level estimates of median household income and poverty rate in 2010--2017

# saipe::set_api_key("<Your API Key Here>")
saipeAPI::saipe_state(year = 2010:2017, var = c("NAME", "SAEMHI_PT", "SAEPOVRTALL_PT"))

County-level data estimates of median household income and poverty rate in 2017

# saipe::set_api_key("<Your API Key Here>")
saipeAPI::saipe_county(year = 2017, var = c("NAME", "SAEMHI_PT", "SAEPOVRTALL_PT"))

Possible Variables and Years

# The pacakge contains a data frame that shows possible variables and variable labels
saipeAPI::saipe_vars

# To get a vector of all possible variables
saipeAPI::saipe_vars$Name

# To get a vector of all possible years
saipeAPI::saipe_years

# Use the above two vectors to download all the US-level data
saipeAPI::saipe_us(year = saipeAPI::saipe_years, var = saipeAPI::saipe_vars$Name)

Future Work



jjchern/saipeAPI documentation built on May 19, 2019, 11:39 a.m.