| do_by {validate} | R Documentation |
split-apply-combine for vectors, with equal-length outptu
Description
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.
Usage
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)
Arguments
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 |
See Also
Other cross-record-helpers:
contains_exactly(),
exists_any(),
hb(),
hierarchy(),
is_complete(),
is_linear_sequence(),
is_unique()
Examples
x <- 1:10
y <- rep(letters[1:2], 5)
do_by(x, by=y, fun=max)
do_by(x, by=y, fun=sum)
[Package validate version 1.1.5 Index]