Rev 48 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{split}\title{Divide into Groups}\usage{split(x, groups)}\alias{split}\arguments{\item{x}{vector containing the values to be divided into groups.}\item{group}{a factor which defines the grouping.}}\description{\code{split} divides the data in the vector \code{x}into the groups defined by the factor \code{groups}.The value returned is a list of vectors containing the valuesfor the groups.The components of the list are named by the factor levels of \code{group}.}\examples{n <- 10; nn <- 100g <- 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 columnsma <- cbind(x = 1:10, y = (-4:5)^2)split(ma, col(ma))}