This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/split.html
split {base}R Documentation

Divide into Groups

Description

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

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 f.

Usage

split(x, f)

Arguments

x

vector containing the values to be divided into groups.

f

a factor which defines the grouping.

Examples

n <- 10; nn <- 100
g <- factor(round(n * runif(n * nn)))
x <- rnorm(n * nn) + sqrt(codes(g))
xg <- split(x, g)
boxplot(xg, col = "lavender", notch = TRUE, varwidth = TRUE)
sapply(xg, length)
sapply(xg, mean)
## Split a matrix into a list by columns
ma <- cbind(x = 1:10, y = (-4:5)^2)
split(ma, col(ma))

[Package base version 0.60 ]