acsdata: Create a list containing ACS data files ('acs').

Description Usage Arguments Value Note Examples

View source: R/acs_data.R

Description

Because downloading the data to compute a proportion, ratio or aggregation can be slow, the acsdata function creates an object that can be used with the sumacs function. Before using this function remember to define a key using the acs command api.key.install(key="*").

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
acsdata(formula, level = "state", dataset = "acs", endyear = 2014,
  span = 5, us = "*", region = "*", division = "*", state = "WI",
  county = "*", county.subdivision = "*", place = "*", tract = "*",
  block.group = "*", msa = "*", csa = "*", necta = "*",
  urban.area = "*", congressional.district = "*",
  state.legislative.district.upper = "*",
  state.legislative.district.lower = "*", puma = "*", zip.code = "*",
  american.indian.area = "*", school.district.elementary = "*",
  school.district.secondary = "*", school.district.unified = "*",
  combine = FALSE, combine.name = "aggregate", print.levels = TRUE)

Arguments

formula

A character or vector of characters containing formulas using ACS/Census variables. + - operators can be included. / defines a division.

level

A character or vector of characters specifying the geographic level of the data. It may be necessary to specificy values to the corresponding levels. For instance, when level = "county", you have to specify a state (e.g., state = "WI", the default state in this package). You can also use a wildcard method (state = "*") to include all the states. Below, you can see the required combinations of different summary levels.


010 us
020 region
030 division
040 state
050 state, county
060 state, county, county.subdivision
140 state, county, tract
150 state, county, tract, block.group
160 state, place
250 american.indian.area
320 state, msa
340 state, csa
350 necta
400 urban.area
500 state, congressional.district
610 state, state.legislative.district.upper
620 state, state.legislative.district.lower
795 state, puma
860 zip.code
950 state, school.district.elementary
960 state, school.district.secondary
970 state, school.district.unified

dataset

A string or vector of strings specifying the data set to be used: acs, sf1 or sf1. The default value is "acs".

endyear

An integer or vector of integers (defaults to 2014) indicating the latest year of the data in the survey or Census year.

span

An integer indicating the span (in years) of the desired ACS data (should be 1, 3,or 5), defaults to 5.

combine

Whether the geographies are to be combined. If combine = TRUE, lists should be used when specifying geographic levels (the corresponding level for the level specified). If the rest geographic levels has one element, the function will assume that level is equal for all the sub-levels. For example, if state = "WI", and several counties were specified, the function assumes that all the counties are from WI.

combine.name

Label for the aggregate geography when combining levels. The default value is aggregate.

print.levels

Boolean that print levels generated by the geo.make function.

Value

Returns a list of ACS objects for different levels to be used with the sumacs function.

Note

Depending on the quality of the internet connection, number of variables and levels, getting the ACS data can be slow especially for the levels "county.subdivision", "block.group", and "tract" (it might take more than 30 minutes).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
api.key.install(key="*")
# get variables from formula
acsdata("(b16004_004 + b16004_026 + b16004_048 / b16004_001)", level = "county")

# get variables directly
acsdata(c("b16004_004", "b16004_026"), level = "county")

# combine levels
acsdata("(b16004_004 + b16004_026 + b16004_048 / b16004_001)",
  level = c("block.group"), state = list("WI"),
  county = list(1, 141),
  tract = list(950100, 11700),
  block.group = list(1:2, 1:2), combine = TRUE)

sdaza/acsr documentation built on June 18, 2020, 6:53 p.m.