DescTools (version 0.99.8.1)

GetPairs: Get All Pairs out of one or two Sets of Elements

Description

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).

Usage

GetPairs(x, y = NULL)

Arguments

x
a vector of elements
y
a vector of elements, need not be same dimension as x. If y is not NULL then all combination x and y are returned.

Value

  • GetPairs returns a data.frame with 2 columns X1 and X2.

Details

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.

See Also

combn, expand.grid, outer, lower.tri

Examples

Run this code
GetPairs(letters[1:4])
GetPairs(x = letters[1:4], y = LETTERS[1:2])

data(d.pizza)
# get all pairs of combinations between factors and numerics out of a data.frame
GetPairs(WhichNumerics(d.pizza), WhichFactors(d.pizza))

Run the code above in your browser using DataLab