isplit: Split Iterator

Description Usage Arguments Value See Also Examples

View source: R/isplit.R

Description

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

Usage

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

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.

Value

The split iterator.

See Also

split

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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 <- nextElem(it)
  stopifnot(actual$value == i)
}

Example output



iterators documentation built on Feb. 5, 2022, 1:06 a.m.