icartes {combiter} | R Documentation |
Cartesian Product Iterator
Description
Create an iterator going through Cartesian product of several items.
Usage
icartes(nvec)
icartesv(...)
Arguments
nvec |
integer vector of number of items |
... |
set of iterables (subsettable by |
Details
icartes
iterates through all combinations of integersicartesv
iterates through all combinations of general values
Value
iterator object
Examples
x <- icartes(c(3, 2, 4))
ct <- 0
while (hasNext(x))
{
ct <- ct + 1
i <- nextElem(x)
cat(sprintf("%3d : %s\n", ct, paste0(i, collapse = " ")))
}
x <- icartesv(Month=c("Jan", "Feb", "Mar"),
Loc=c("NY", "LA"),
By=c("car", "plane", "bus"))
as.list(x)
[Package combiter version 1.0.3 Index]