split
divides the data in a vector-like object x
into the
groups defined by f
. NOTE: This man page is for the split
methods defined in the
S4Vectors package. See ?base::split
for the
default method (defined in the base package).
"split"(x, f, drop=FALSE)
"split"(x, f, drop=FALSE)
"split"(x, f, drop=FALSE)
"split"(x, f, drop=FALSE, ...)
f
will typically be a
factor, but not necessarily.
f
is a factor).
base::split
(see Details below).
IRanges::splitAsList
function defined in the
IRanges package. The method for list
does:
split(x, as.vector(f), drop=drop, ...)
## On an Rle object:
x <- Rle(101:105, 6:2)
split(x, c("B", "B", "A", "B", "A"))
## On a DataFrame object:
groups <- c("group1", "group2")
DF <- DataFrame(
a=letters[1:10],
i=101:110,
group=rep(factor(groups, levels=groups), c(3, 7))
)
split(DF, DF$group)
Run the code above in your browser using DataLab