Download and load U.S. census American Community Survey 5-year summary files at the block group level, optionally including home-work commute statistics.

download_census_population(dir, state, year = 2019,
  include_margins = FALSE, include_commutes = FALSE, counties = NULL,
  tracts = NULL, blockgroups = NULL, overwrite = FALSE, verbose = TRUE)

Arguments

dir

Directory in which to save the file(s).

state

Name, abbreviation, or FIPS code of the state.

year

4 digit year, between 2009 and the most recent year.

include_margins

Logical; if TRUE, will save and include estimate margins or error, which is a data.frame with the same dimensions as the estimates data.frame.

include_commutes

Logical; if TRUE, will download the Longitudinal Employer-Household Dynamics (LEHD) Origin-Destination Employment Statistics (LODES) data for the state and block groups within selected tracts.

counties, tracts, blockgroups

A vector of counties, tracts, or block group GEOIDs within the specified state to filter block groups for (block groups within the specified counties or tracts, or matching the specified block group GEOID). Only one can be specified (lower levels overwrite higher levels). Defaults to all block groups.

overwrite

Logical; if TRUE, will remove any existing files before downloading and saving new versions.

verbose

Logical; if FALSE, will not print status messages.

Value

A list with at least an estimates entry, and optionally margins and/or commutes

entries. The extimates and margins entries are data.frames with block groups in rows, population variables in columns, and person counts in cells. The commutes entry is a sparse matrix with home block groups in rows, work block groups in columns, and job counts in cells (all jobs, summed across blocks).

Examples

if (FALSE) {
download_census_population(".", "va")
}