# pair.matrix

0th

Percentile

##### Given a vector of elements, create a two-column matrix listing all pairs of elements

This function takes in a vector and returns a matrix of all pairs of the elements. The order of pairs can be ignored or taken into account, and self-pairs can either be included or ignored.

Keywords
internal
##### Usage
pair.matrix(elements, ordered = FALSE, self.pairs = FALSE)
##### Arguments
elements
A vector of elements for which all pairs are wanted. This vector can include numeric values, strings, or a mixture of both.
ordered
A logical value indicating whether order of pairs is important. TRUE indicates that pair 'a-b' is different from 'b-a'. A value of FALSE will return only one of these pairs.
self.pairs
A logical value indicating whether elements should be paired with themselves ('a-a'). A value of TRUE will return a matrix including self pairs.
##### Value

A two-column matrix of all pairwise combinations of the vector elements is returned.

• pair.matrix
##### Examples
el <- letters[1:4]
letter.pairs <- pair.matrix(el, ordered = FALSE, self.pairs = FALSE)
print(letter.pairs)

el <- 1:4
num.pairs <- pair.matrix(el, ordered = FALSE, self.pairs = TRUE)
print(num.pairs)

Documentation reproduced from package cape, version 2.0.2, License: GPL-3

### Community examples

Looks like there are no examples yet.