grp_reverse_pairs | R Documentation |
Given a list of unique value pairs such as "A-B" and "B-A", both are assigned the same id.
grp_reverse_pairs(x, as_fct = F)
x |
Data frame with two columnes to be matched |
as_fct |
Logical. If resulting shared identifier should be a factor. |
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".
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.
mreverse
x <- data.frame(a=c(1,2,3,4,5,1), b=c(2,1,4,3,5,2))
grp_reverse_pairs(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.