R: Split a data frame

by-split {doBy} | R Documentation

## 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

    split_by(data, formula, drop = TRUE)

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

### Arguments

`data` | A data frame
`formula` | Variables to split data frame by, as ‘as.quoted’ variables, a formula or character vector.
`drop` | Logical indicating if levels that do not occur should be dropped. Deprecated; levels that do not occur are ignored.

### Value

A list of dataframes.

### Author(s)

Søren Højsgaard, sorenh@math.aau.dk

### See Also

`orderBy`, `summaryBy`, `transformBy`

### Examples

    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)

[Package doBy version 4.6.6 Index]