Description Usage Arguments Functions Examples
pct_routine
works like count
except that it
returns group percentages instead of counts. tally_pct
is a underlying
utility function that corresponds to tally
. As the name implies, it
also returns percentage.
1 2 3 4 5 6 7 8 9 |
data |
A |
... |
Variables to group by, see |
wt |
Column name of weights. |
ret_name |
Character of the variable name returned. |
rebase |
Whether to remove the missing values in the percentage, e.g. rebase the percentage so that NAs in the last group are excluded. |
ungroup |
Whether to ungroup the returned table. |
vars |
A character vector of variable names to group by. |
pct_routine_
: SE version of pct_routine
.
tally_pct
: NSE version of tally_pct_
.
tally_pct_
: Underlying SE function of pct_routine_
without
options for groups.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | data(esoph)
esoph
pct_routine(esoph, agegp, alcgp)
pct_routine(esoph, agegp, alcgp, wt = ncases)
# Crate new grouping variables
pct_routine(esoph, agegp, low_alcgp = alcgp %in% c("0-39g/day", "40-79"))
# This examples shows how rebase works
if (require(dplyr)) {
iris %>%
mutate(random_missing = ifelse(rnorm(n()) > 0, NA, round(Sepal.Length))) %>%
group_by(Species, random_missing) %>%
tally_pct(wt = Sepal.Width, rebase = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.