icartes | R Documentation |
Create an iterator going through Cartesian product of several items.
icartes(nvec)
icartesv(...)
nvec |
integer vector of number of items |
... |
set of iterables (subsettable by |
icartes
iterates through all combinations of integers
icartesv
iterates through all combinations of general values
iterator object
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.