I have a dataframe such as ;
COL1 COL2
A,A,A 2
B 1
C,C 4
D,D,D 1
A 4
F 2
C,C 1
And I would like to first remove duplicate within COL1 and get:
COL1 COL2
A 2
B 1
C 4
D 1
A 4
F 2
C 1
and then sum the same COL1 letter by the COL2 values and get :
COL1 COL2
A 6
B 1
C 5
D 1
F 2
Does someone have an idea, please? Here is the dataframe if it can helps:
structure(list(COL1 = structure(c(2L, 3L, 4L, 5L, 1L, 6L, 4L), .Label = c("A",
"A,A,A", "B", "C,C", "D,D,D", "F"), class = "factor"), COL2 = c(2,
1, 4, 1, 4, 2, 1)), class = "data.frame", row.names = c(NA, -7L
))