[R] grouping similar column values into a single row

T Joshi tejalonline at gmail.com
Sun Nov 30 19:08:04 CET 2008

I have a following situation with data:
col1   col2
mir-1 aaa
mir-1 abc
mir-1 aac
mir-2 abb
mir-2 aaa
mir-3 cag
mir-3 ccc
mir-3 aaa

I want to have  output in this format:
col1     col2
mir-1 aaa, abc, aac
mir-2 abb, aaa
mir-3 cag,ccc,aaa

I have sorted column 1 so that the grouping could be possible. I could
have done the same with mysql using a simple query, but I am not sure
how I can do it in R. Please suggest me possible way.


More information about the R-help mailing list