Split a data frame

R doBy

splitBy(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

splitBy(formula, data = parent.frame(), drop=TRUE, return.matrix=FALSE)
## S3 method for class 'splitByData':
print(x, ...)

Arguments

formula The right hand side of a formula (or a character vector)
data A data frame
drop Logical indicating if levels that do not occur should be dropped
return.matrix Should the returned list consist of dataframs or matrices, see 'details' below
x A splitByData object (basically a list).
... Additional arguments, currently not used.

Details

The funcion transform the dataframe 'data' into a numerical matrix (using the 'asNumericMatrix' function from the Hmisc package) and makes the splitting operation on this. If return.matrix is TRUE, then these matrices are returned, otherwise the matrices are turned into dataframes and then these are returned.

Value

A list of dataframes of matrices

Author(s)

Søren Højsgaard, [email protected]

See Also

orderBy, summaryBy, transformBy, lapplyBy,

Examples

data(dietox)
splitBy(formula = ~Evit+Cu, data = dietox)

[Package doBy version 4.0.2 Index]