Learn R Programming

iterors (version 1.0)

isplit: Split Iterator

Description

Returns an iterator that divides the data in the vector x into the groups defined by f.

Usage

isplit(x, f, drop = FALSE, ...)

Value

The split iterator.

Arguments

x

vector or data frame of values to be split into groups.

f

a factor or list of factors used to categorize x.

drop

logical indicating if levels that do not occur should be dropped.

...

current ignored.

Details

Originally from the iterators package.

See Also

Examples

Run this code

x <- rnorm(200)
f <- factor(sample(1:10, length(x), replace = TRUE))

it <- isplit(x, f)
expected <- split(x, f)

for (i in expected) {
    actual <- nextOr(it, break)
    stopifnot(actual$value == i)
}

Run the code above in your browser using DataLab