CombPairs | R Documentation |
Returns all combinations of 2 out of the elements in x or x and y (if defined). Combinations of the same elements will be dropped (no replacing).
CombPairs(x, y = NULL)
x |
a vector of elements |
y |
a vector of elements, need not be same dimension as x.
If y is not |
If y = NULL
then all combination of 2 out of x are returned.
If y is defined then all combinations of x and y are calculated.
CombPairs
returns a data.frame with 2 columns X1 and X2.
Andri Signorell <andri@signorell.net>
combn
, expand.grid
, outer
, lower.tri
CombPairs(letters[1:4])
CombPairs(x = letters[1:4], y = LETTERS[1:2])
# get all pairs of combinations between factors and numerics out of a data.frame
CombPairs(which(sapply(d.pizza, IsNumeric)), which(sapply(d.pizza, is.factor)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.