[ top | up ]

Divide into Groups

Syntax

split(x, groups)

Arguments

x vector containing the values to be divided into groups.
group a factor which defines the grouping.

Description

split divides the data in the vector x into the groups defined by the factor groups.

The value returned is a list of vectors containing the values for the groups. The components of the list are named by the factor levels of group.

Examples

xa <- split(x, age) lapply(xa, mean) #split a matrix into a list by columns split(x,col(x))