Suppose I have a data.frame such as:
df = data.frame(id = c("a","b","c","d","e"), tid = rep("t",5), gid = c("A","B","C","D","E"), V1 = c("11","11","11","00","11"), V2 = c("11","01","11","01","01"), V3 = c("11","11","11","10","11"))
and I would like to aggregate rows that are identical between columns 4-6 (all columns but the first three). The first three column fields which correspond to aggregated rows should be the concatenation (comma separated) of their original values.
So for my example this would be the resulting data,frame:
> df
id tid gid V1 V2 V3
1 a,c t A,C 11 11 11
2 b,e t B,E 11 01 11
3 d t D 00 01 10
What's the simplest/fastest way to achieve this?