read_acs5year: Read ACS 5-year estimates

View source: R/read_acs5year.R

read_acs5yearR Documentation

Read ACS 5-year estimates

Description

This function retrieves data from summary file of ACS 5-year estimates. In addition to selected geographic headers and table contents, it also returns total population and coordinates of selected geographic areas, as well as summary levels and geographic components.

Usage

read_acs5year(
  year,
  states,
  table_contents = NULL,
  areas = NULL,
  geo_headers = NULL,
  summary_level = NULL,
  geo_comp = "total",
  with_margin = FALSE,
  dec_fill = NULL,
  show_progress = TRUE
)

Arguments

year

ending year of the 5-year estimate

states

vector of state abbreviations, such as "IN" and c("MA", "RI").

table_contents

selected references of contents in census tables. Users can choose a name for each reference, such as in c("abc = B01001_009", "fff = B00001_001"). Try to make names meaningful. To find the references of table contents of interest, search with function search_tablecontents.

areas

For metro area, in the format like "New York metro". For county, city, or town, must use the exact name as those in dict_fips in the format like "kent county, RI", "Boston city, MA", and "Lincoln town, RI". And special examples like "Salt Lake City city, UT" must keep the "city" after "City".

geo_headers

vector of references of selected geographci headers to be included in the return, like "COUNTY" or c("PLACE", "CBSA"). Search with search_geoheaders

summary_level

select which summary level to keep, default to keep all. It takes string including "state", "county", "county subdivision", "place", "tract", "block group", and "block" for the most common levels. It also take code. Search all codes with search_summarylevels.

geo_comp

select which geographic component to keep, "*" to keep every geo-component, "total" for "00", "urban" for "01", "urbanized area" for "04", "urban cluster" for "28", "rural" for "43". Others should input code, which can be found with function search_geocomponents. Availability of geocomponent depends on summary level.

with_margin

read also margin of error in addition to estimate

dec_fill

whether to fill geo_headers codes with data from decennial census. The codes in ACS summary file are incomplete. "dec2010" using decennial census 2010 data

show_progress

whether to show progress in fread()

Value

A data.table of selected data.

Examples

## Not run: 
# read data using areas
aaa <- read_acs5year(
    year = 2015,
    states = c("UT", "RI"),
    table_contents = c(
        "white = B02001_002",
        "black = B02001_003",
        "asian = B02001_005"
    ),
    areas = c(
        "Lincoln town, RI",
        "Salt Lake City city, UT",
        "Salt Lake City metro",
        "Kent county, RI",
        "COUNTY = UT001",
        "PLACE = UT62360"
    ),
    summary_level = "block group",
    with_margin = TRUE
)


# read data using geoheaders
bbb <- read_acs5year(
    year = 2015,
    states = c("UT", "RI"),
    table_contents = c("male = B01001_002", "female = B01001_026"),
    geo_headers = "PLACE",
    summary_level = "block group"
)

## End(Not run)


GL-Li/totalcensus documentation built on Jan. 30, 2024, 9:07 p.m.