sumacs: Estimate proportions, ratios, aggregations and the respective...

Description Usage Arguments Details Value Note Examples

View source: R/sum_acs.R

Description

The sumacs function uses outputs from the acs package to compute proportions, ratios and aggregations based on text formulas, or simply extract variables. The function downloads the data and then estimate the formulas. If the function is used without specifying any data, remember to define a key using the acs command api.key.install(key="*").

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sumacs(formula, varname = NULL, method = "variable", level = "state",
  dataset = "acs", endyear = 2014, span = 5, conf.level = 0.9,
  one.zero = TRUE, trace = TRUE, data = NULL, format.out = "wide",
  file = NULL, print.levels = TRUE, 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")

Arguments

formula

A character or vector of characters containing formulas using ACS/Census variables or just variables. + - operators can be included. / defines a division. When the formula contains "* 100", the final statistic and MOE is multiply by 100.

varname

A character or vector of characters containing the new variables to be created. This vector must have same length as formula and method, and it is not needed when getting only variables.

method

A character or vector of characters defining the type of estimate expected: "proportion", "ratio", "aggregation", "variable". This vector must have same length as formula and varname. It is not needed when getting only variables. Default value "variable".

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

When combine == TRUE, the geographic information should be in a list.

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 (default is 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.

conf.level

Confidence level to estimate MOEs. The default value is 0.90.

one.zero

Whether to include standard errors for only one zero-value (max value) of columns or all. The default is TRUE.

trace

Shows progress of the variable creation. The default is TRUE.

data

Input data generated by the acsdata function. Variables and levels must be the same as those specified in the sumacs function.

format.out

Format of the output: "wide" or "long". The default is "wide".

file

The resulting output is exported to a CSV file rather than to the R prompt. The file name must be specified as a character string.

print.levels

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

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.

Details

When the standard error of a proportion cannot be estimated, the "ratio" option is used. This adjustment is done row by row.

Value

Returns a data.table/data.frame object with the estimates and MOEs.

Note

Depending on the quality of the internet connection, number of variables and levels, getting the ACS/Census data can be slow, especially for the levels "county.subdivision", "block.group", and "tract" (it might take more than 30 minutes). It is recommended to get the data using the function acsdata first, and then to use sumacs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# api.key.install(key="*")

# without combining
sumacs(formula = "(b16004_004 + b16004_026 + b16004_048 / b16004_001)",
 varname = "langspan0913", method = "prop")

# combining
sumacs("(b16004_004 + b16004_026 + b16004_048 / b16004_001)",
 varname = "test",
 method = "prop",
 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.