by-split | R Documentation |
Split a dataframe according to the levels of variables in the dataframe. The variables to split by can be given as a formula or as a character vector.
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 |
... |
A character vector or, right hand sided formula or a listing of variables. |
omit |
Logical Should variables split on be omitted from the output. Defaults to TRUE. |
formula |
A character vector or a right hand sided formula. |
x |
An object. |
n |
A single integer. If positive or zero, size for the resulting object: number of elements for a vector (including lists), rows for a matrix or data frame or lines for a function. If negative, all but the "n" last/first number of elements of "x". |
drop |
Obsolete |
A list of dataframes.
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)
x <- CO2 |> split_by(~Treatment)
head(x, 3)
tail(x, 3)
x <- CO2 |> split_by(~Treatment, omit=FALSE)
head(x, 3)
tail(x, 3)
## 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.