View source: R/survey_count_tally.R
survey_tally | R Documentation |
Analogous to tally
and count, calculates the survey weighted
count of observations. survey_tally
will call survey_total
empty (resulting
in the count of each group) or on wt
if it is specified (resulting in the
survey weighted total of wt
). survey_count
is similar, but calls group_by
before calculating the count and then returns the data to the original groupings.
survey_tally( x, wt, sort = FALSE, name = "n", vartype = c("se", "ci", "var", "cv") ) survey_count( x, ..., wt = NULL, sort = FALSE, name = "n", .drop = dplyr::group_by_drop_default(x), vartype = c("se", "ci", "var", "cv") )
x |
A tbl_svy object, as created by |
wt |
(Optional) A variable to weight on (in addition to the survey weights,
which are always used). If left unspecified, |
sort |
Whether to sort the results (defaults to |
name |
Name of count variable created (defaults to n). If the variable already exists, will add "n" to the end until it does not. |
vartype |
What types variation estimates to calculate, passed to
|
... |
Variables to group by, passed to |
.drop |
When .drop = TRUE, empty groups are dropped, see |
If n
already exists, tally
will use it as the weight, but count
will not.
library(survey) data(api) dstrata <- apistrat %>% as_survey_design(strata = stype, weights = pw) dstrata %>% group_by(awards) %>% survey_tally() dstrata %>% survey_count(awards)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.