Learn R Programming

doBy (version 4.6-2)

by-split: Split a data frame

Description

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.

Usage

splitBy(formula, data = parent.frame(), drop = TRUE)

Arguments

formula

Variables to split data frame by, as <U+2018>as.quoted<U+2019> variables, a formula or character vector.

data

A data frame

drop

Logical indicating if levels that do not occur should be dropped. Deprecated; levels that do not occur are ignored.

...

Additional arguments, currently not used.

Value

A list of dataframes.

See Also

orderBy, summaryBy, transformBy

Examples

Run this code
# NOT RUN {
data(dietox, package="doBy")
splitBy(formula = ~Evit + Cu, data = dietox)
splitBy(formula = c("Evit", "Cu"), data = dietox)

splitBy(~Month, data=airquality)
splitBy("Month", data=airquality)

# }

Run the code above in your browser using DataLab