Question:
I have a square matrix that is like:
I tried to first combine the rows with the same “Codes” number, but I was having a lot of trouble.
Answer:
In tidyverse
One way in base R:
Note that this can be simplified as denoted by
@thelatemail to
If you have better answer, please add a comment about this, thank you!