split-methods: Divide a vector-like object into groups

Description Usage Arguments Details Value See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S4 method for signature 'Vector,ANY'
split(x, f, drop=FALSE)

## S4 method for signature 'ANY,Vector'
split(x, f, drop=FALSE)

## S4 method for signature 'Vector,Vector'
split(x, f, drop=FALSE)

## S4 method for signature 'list,Vector'
split(x, f, drop=FALSE, ...)

Arguments

x, f

2 vector-like objects of the same length. f will typically be a factor, but not necessarily.

drop

Logical indicating if levels that do not occur should be dropped (if f is a factor).

...

Arguments passed to base::split (see Details below).

Details

The first 3 methods just delegate to the IRanges::splitAsList function defined in the IRanges package.

The method for list does:

1

Value

All these methods behave like base::split except that the first 3 methods return a List object instead of an ordinary list.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

AdamLeckenby/S4Vectors_Fix documentation built on May 23, 2019, 2:42 p.m.