3
need to return the class of a specific id to a table. Often a single id encodes several classes:
id<-c("A","B","C","D","C","B","A")
clas<-c(1,2,2,2,3,3,4)
tab<-data.frame(id,clas)
What I need to do is make a data.frame that returns as follows:
id clas
1 1 A
2 2 BCD
3 3 CB
4 4 A
Can someone help me
His idea was great and very simple, a tiny correction in the script is to exchange id with Clas: tab_resutlado <- tab %>% group_by(Clas) %>% summarise(id = paste0(id, Collapse = ""))
– Vivian Ribeiro
Is it OK to do this with a 1 million line table? it summarizes the classes in 6 lines and does not return the table
– Vivian Ribeiro
Shouldn’t... Are you sure you want to do the group by Clas? I think in your example it’s reversed!
– Daniel Falbel