icomb {combiter} | R Documentation |
Combination Iterator
Description
Create an iterator for all combinations k integers out of 1 through n.
Usage
icomb(n, k)
icombv(values, k)
Arguments
n |
positive integer |
k |
positive integer no greater than n |
values |
iterable (subsettable by |
Details
icomb
iterates through integer vectorsicombv
iterates through general values
Value
iterator object
Examples
x <- icomb(5, 3)
ct <- 0
while (hasNext(x))
{
ct <- ct + 1
i <- nextElem(x)
cat(sprintf("%3d : %s\n", ct, paste0(i, collapse = " ")))
}
as.list(icombv(c("A", "G", "C"), 2))
[Package combiter version 1.0.3 Index]