If the data set regular have 2 columns ‘ID’ and ‘Answer’, but the ‘ID’ is not unique. That means one ID can have 2 or more Answer. We want to put all the Answer for the same ID into one cell, kind of grouping them into one. aggregate is useful for this case.
regular
##It will show
## ID Answer
## 1 A
## 2 B
## 2 C
## 3 A
## 1 D
trial<-aggregate(ANSWER ~ COMM_ID, data = regular, paste, collapse = “,,,”)
trial
##It will show
## ID Answer
## 1 A,,,D
## 2 B,,,C
## 3 A