combine.output: Estimate proportions, ratios, aggregations and the respective...

Description Usage Arguments Details Value Note Examples

View source: R/combine_output.R

Description

Using the sumacs function, it computes proportions, ratios and aggregations based on text formulas, or simply extract variables of combinations of geographic units. It uses the same procedures of the sumacs function, but the geographic level and information have to be specified in lists (they can be nested).

Usage

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

Arguments

formula

A character or vector of characters containing formulas using ACS 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", "variables". This vector must have same length as formula and varname. It is not needed when getting only variables.

level

A list specifying the geographic level of the data. It may be necessary to specify values to the corresponding levels. For instance, when level = list("county"), you have to specify a state (e.g., state = list("WI"), the default state in this package), and the counties you want to combine: county = list(1,2). They may be also nested lists (e.g., county = list( list(1:2, 3:4), list(5:6, 7:8) )). The number of elements of the level list should be the same as combine.names) (names of combined groups, see below).

The required combinations of different summary levels are:


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

combine.names

Labels for the aggregate geographies. It should be the same as the number of elements of the list level.

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.

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.

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.

data

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

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 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
# api.key.install(key="*")
  combine.output("(b16004_004 + b16004_026 + b16004_048 / b16004_001)",
    varname = "myvar",
    method = "prop",
    level = list("division", "division"),
    division = list(list(1:2, 3), list(1:2, 3:4)),
    combine.names = c("g1", "g2"))

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