Description Usage Arguments Value Examples
View source: R/group.estimate.R
Collect point estimate, standard error and 90
any statistic across groups defined by gp.var
and (optionally)
over the whole data. If x is grouped already, gp.var
is added
to the grouping, but in this case, gp.var
can be NULL,
which does not add a new grouping.
1 2 | group.estimate(x, f, gp.var, ..., result.name = NULL, drop.na.group = FALSE,
include.total = TRUE)
|
x |
a data frame of PUMS data. If x is already grouped, then this function optionally adds a level to the grouping. |
f |
a function to calculate the statistic.
It must take data and a weight replicate number called
|
gp.var |
name of variable in x to group data by (string) or NULL if x is grouped and you do not want to add a level of grouping. May not be NULL if x is not grouped. |
... |
other data passed to f |
result.name |
name of estimate column in result.
Default of NULL uses |
drop.na.group |
default FALSE, drop the group where |
include.total |
include the total across all groups, default TRUE |
data frame of estimate, standard error of the estimate,
and the margin of error of the estimate, for the statistic
defined by 'f', over the groups defined by gp.var
and (optionally) the whole data.
1 2 3 4 5 6 7 8 9 10 11 | # Total of occupied households in Washington State in 2016
group.estimate(wa.house16, estimate, 'TEN', drop.na.group=TRUE)
# 90% household income by tenure type for Washington State in 2016
group.estimate(wa.house16, acs.quantile, 'TEN', field='HINCP',
probs=0.9, result.name='HH.Inc90', drop.na.group = TRUE)
# First example, with data already grouped using group_by
library(dplyr)
gp <- group_by(wa.house16, TEN)
group.estimate(gp, estimate, NULL, drop.na.group=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.