Learn R Programming

DescTools (version 0.99.56)

CombPairs: 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

CombPairs(x, y = NULL)

Value

CombPairs returns a data.frame with 2 columns X1 and X2.

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.

Author

Andri Signorell <andri@signorell.net>

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

Examples

Run this code
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)))

Run the code above in your browser using DataLab