partition {funprog} | R Documentation |
Partition a vector in two
Description
Split a vector or a list in 2 groups, given a predicate function.
Usage
partition(x, predicate)
Arguments
x |
vector or list to partition. |
predicate |
a function returning a boolean value, to apply to each element of x. |
Value
A list of two elements. The first element contains elements of x satisfying the predicate, the second the rest of x. Missing values will be discarded.
Examples
partition(c(2, 1, 3, 4, 1, 5), function(x) x < 3)
partition(list(1:3, NA, c(1, NA, 3)), anyNA)
[Package funprog version 0.3.0 Index]