grp_reverse_pairs: Assigns shared identifier to reversed value pairs

View source: R/mreverse.R

grp_reverse_pairsR Documentation

Assigns shared identifier to reversed value pairs

Description

Given a list of unique value pairs such as "A-B" and "B-A", both are assigned the same id.

Usage

grp_reverse_pairs(x, as_fct = F)

Arguments

x

Data frame with two columnes to be matched

as_fct

Logical. If resulting shared identifier should be a factor.

Details

A unique list of value pairs is created first. Value- and reverse-value pairs are then matched. The first occurence of a value pair will be used as shared name. Thus, if "A-B" is first, both "A-B" and "B-A" will be named "A-B".

Value

Original data frame with additional column identifying matching pairs. Column names are "a", "b" and shared value "g". Duplicated entries are removed from original list; each value - reverse value pair occurs exactly once.

See Also

mreverse

Examples

x <- data.frame(a=c(1,2,3,4,5,1), b=c(2,1,4,3,5,2))
grp_reverse_pairs(x)


jmueller17/sociometrics documentation built on March 20, 2024, 1:04 a.m.