comboGrid | R Documentation |
expand.grid
Where order Does Not Matter
This function efficiently generates Cartesian-product-like output where order does not matter. It is loosely equivalent to the following:
t = expand.grid(list)
t = t[do.call(order, t), ]
key = apply(t, 1, function(x) paste0(sort(x), collapse = ""))
t[!duplicated(key), ]
comboGrid(..., repetition = TRUE)
... |
vectors, factors or a list containing these. (See |
repetition |
Logical value indicating whether results should be with or without repetition. The default is |
If items with different classes are passed, a data frame will be returned, otherwise a matrix will be returned.
Joseph Wood
## return a matrix
expGridNoOrder = comboGrid(1:5, 3:9, letters[1:5], letters[c(1,4,5,8)])
head(expGridNoOrder)
tail(expGridNoOrder)
expGridNoOrderNoRep = comboGrid(1:5, 3:9, letters[1:5],
letters[c(1,4,5,8)], repetition = FALSE)
head(expGridNoOrderNoRep)
tail(expGridNoOrderNoRep)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.