by-split | R Documentation |
Split a dataframe according to the levels of variables in the dataframe. Uses vparse() to interpret flexible input.
split_by(data., ..., omit = TRUE)
splitBy(formula, data, omit = TRUE)
## S3 method for class 'splitByData'
head(x, n = 6L, ...)
## S3 method for class 'splitByData'
tail(x, n = 6L, ...)
split_by.legacy(data, formula, drop = TRUE)
splitBy.legacy(formula, data = parent.frame(), drop = TRUE)
data. |
A data frame (or tibble) to split |
... |
Variables defining the groups |
omit |
If TRUE (default), group-defining variables are omitted in each split group |
formula |
A right hand sided formula (for the old interface) |
data |
A data frame (for the old interface) |
x |
A splitByData object. |
n |
An integer vector. |
drop |
Obsolete |
An object of class \"splitByData\" (a named list with group attributes)
Søren Højsgaard, sorenh@math.aau.dk
orderBy
, order_by
,
summaryBy
, summary_by
,
transformBy
, transform_by
split_by(CO2, ~Treatment+Type)
split_by(CO2, Treatment, Type)
split_by(CO2, c("Treatment", "Type"))
split_by(CO2, "Treatment", "Type")
x <- split_by(CO2, "Treatment", "Type")
head(x, 3)
tail(x, 3)
## Via wrapper:
foo2 <- function(x) {
x <- rlang::enquo(x)
split_by(CO2, !!x)
}
foo2(~Treatment)
## The "Old" interface
splitBy(~Treatment + Type, CO2)
splitBy(~Treatment + Type, data=CO2)
splitBy(c("Treatment", "Type"), data=CO2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.