0
votes

I am trying to find the most common pairs across 5 variables, very similar to this question. The main difference is I'd have one more variable that I'd like to group them by.

data.frame':   430 obs. of  6 variables:
 $ group: chr  "Celtics" "Pelicans" "Suns" ...
 $ X1  : int  7 9 22 15 34 11 21 35 33 43 ...
 $ X2  : int  22 16 31 40 49 15 11 13 41 50 ...
 $ X3  : int  30 17 36 32 29 36 41 34 1 2 ...
 $ X4  : int  48 29 8 45 21 9 6 6 18 8 ...
 $ X5  : int  16 39 32 12 27 43 12 15 23 7 ...
 

The output I'd like would look like this:

   group             Pair                   n
   <chr>             <dbl>                  <dbl>
 1 Suns              41-23                  30

I don't have a good enough grasp of using the combn function with group_by and a dplyr mutate to make this work yet. Any help would be appreciated.