I have a dataframe mydf
. I want to get the count for each item in combination column to get the result as shown below.
mydf <-structure(c("AMLM12001KP", "AMLM120XP", "AMLM12001KP", "1231401",
"1231401", "1231401", "ANKRD30BL*", "WDR70*NXPH1", "WDR70*NXPH1",
"FGGY*", "LIN28A*DFNB59", "AK2*"), .Dim = c(6L, 2L), .Dimnames = list(
NULL, c("customer_sample_id", "combination")))
result
combination frequency customer_sample_id
ANKRD30BL* 1 sample AMLM12001KP
WDR70*NXPH1 2 sample AMLM120XP, AMLM12001KP
FGGY* 1 sample 1231401
LIN28A*DFNB59 1 sample 1231401
AK2* 1 sample 1231401