do_by | R Documentation |
Group x
by one or more categorical variables, compute
an aggregate, repeat that aggregate to match the size of the
group, and combine results. The functions sum_by
and
so on are convenience wrappers that call do_by
internally.
do_by(x, by, fun, ...)
sum_by(x, by, na.rm = FALSE)
mean_by(x, by, na.rm = FALSE)
min_by(x, by, na.rm = FALSE)
max_by(x, by, na.rm = FALSE)
x |
A bare variable name |
by |
a bare variable name, or a list of bare variable names, used to
split |
fun |
|
... |
passed as extra arguments to |
na.rm |
Toggle ignoring |
Other cross-record-helpers:
contains_exactly()
,
exists_any()
,
hb()
,
hierarchy()
,
is_complete()
,
is_linear_sequence()
,
is_unique()
x <- 1:10
y <- rep(letters[1:2], 5)
do_by(x, by=y, fun=max)
do_by(x, by=y, fun=sum)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.