sumacs | R Documentation |
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="*")
.
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"
)
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
|
method |
A character or vector of characters defining the type of
estimate expected: "proportion", "ratio", "aggregation", "variable". This
vector must have same length as |
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
When |
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 |
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 |
combine |
Whether the geographies are to be combined. If |
combine.name |
Label for the aggregate geography when combining levels.
The default value is |
When the standard error of a proportion cannot be estimated, the "ratio" option is used. This adjustment is done row by row.
Returns a data.table/data.frame
object with the estimates and
MOEs.
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
.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.