See ?tapply
> tapply(paste(DF$col2), DF$col1, c)
$`mir-1`
[1] "aaa" "abc" "aac"
$`mir-2`
[1] "abb" "aaa"
$`mir-3`
[1] "cag" "ccc" "aaa"
> # or
> t(t(tapply(paste(DF$col2), DF$col1, paste, collapse = " ")))
[,1]
mir-1 "aaa abc aac"
mir-2 "abb aaa"
mir-3 "cag ccc aaa"
> # or
> t(do.call(cb
Hi,
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 p
2 matches
Mail list logo