I have this data frame
df<-data.frame(ID=c(1,1,2,2,2),A=c(1,2,1,2,3),B=c("A","T","T","A","G"))
ID A B
1 1 1 A
2 1 2 T
3 2 1 T
4 2 2 A
5 2 3 G
and I need this summarize table
summary_df <- data.frame(ID = c(1,2), sort_factor_and_combin_B = c("A-T","A-T-G"))
ID sort_factor_and_combin_B
1 1 A-T
2 2 A-T-G
Regardless of the order of column A, I want to create a column that contains the characters that are concatenated in alphabetical order with the factors in column B that each ID has.
2. At the same time, I also want a column that joins according to the order of A.
do you have any idea?
thank you!