I have a dataframe in R as below
bacteria sample
1 A HM_001
2 B HM_001_HM_001
3 C A2_HM_001
4 D A2_HM_001_HM_001
5 E HM_002
6 F HM_002_HM_002
7 G A2_HM_002
8 H A2_HM_002_HM_002
and wish to remove duplicated substrings down the sample
column so that the final output is as below:
bacteria sample
1 A HM_001
2 B HM_001
3 C A2_HM_001
4 D A2_HM_001
5 E HM_002
6 F HM_002
7 G A2_HM_002
8 H A2_HM_002