CombPairs.Rd
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)
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.
CombPairs(letters[1:4])
#> X1 X2
#> 1 a b
#> 2 a c
#> 3 a d
#> 4 b c
#> 5 b d
#> 6 c d
CombPairs(x = letters[1:4], y = LETTERS[1:2])
#> Var1 Var2
#> 1 a A
#> 2 b A
#> 3 c A
#> 4 d A
#> 5 a B
#> 6 b B
#> 7 c B
#> 8 d B
# 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)))
#> Var1 Var2
#> 1 1 5
#> 2 11 5
#> 3 1 9
#> 4 11 9
#> 5 1 10
#> 6 11 10
#> 7 1 16
#> 8 11 16