I would like to get some help with the following problem and understand how this can be done in R efficiently. The header is given in the data frame.
Component, TLA
C1, TLA1
C2, TLA1
C1, TLA2
C3, TLA2
C4, TLA3
C5, TLA3
Notice that C1
is a component of TLA1
and TLA2
.
I would like to form groups of mutually exclusive subsets and create a new column called group for this subset. For the above data, the subsets and the new group column value will be like so:
Component, TLA, Group
C1, TLA1, 1
C2, TLA1, 1
C1, TLA2, 1
C3, TLA2, 1
C4, TLA3, 2
C5, TLA3, 2
Appreciate any help on this. I could have looped through the observations and tried some logic but I did not try that yet.