I have a column with common levels as reps (1-4). I have data that goes with them in col3. Some of the levels don't contain information but for the ones that do, I would like to merge the values into one column by each common level in col1. The values in col3 are not consistent.
I have tried removing duplicates but this does not merge col3 values.
train <- data.table(col1=c(rep('a0001',4),rep('b0002',4)), col2=c(seq(1,4,1),seq(1,4,1)), col3=c("12 43 543 1232 43 543", "","","","15 24 85 64 85 25 46","","658 1568 12 584 15684",""))
this is reproducible code I have about 40000 lines to do.
result<-data.frame(col1=c("a0001","b0002"),col3=c("12 43 543 1232 43 543",'15 24 85 64 85 25 46 658 1568 12 584 15684'))
This is the result I am looking for...