I have a very large data.table
with 4 columns, only one of which is totally unique. Hard to explain but it looks like this:
ENSEMBL ENTREZID SYMBOL ALIAS
1 ENSG00000000003 7105 TSPAN6 T245
2 ENSG00000000003 7105 TSPAN6 TM4SF6
3 ENSG00000000003 7105 TSPAN6 TSPAN-6
4 ENSG00000000003 7105 TSPAN6 TSPAN6
5 ENSG00000000005 64102 TNMD BRICD4
6 ENSG00000000005 64102 TNMD CHM1L
I'm trying to collapse it based on the first 3 columns, and make the ALIAS
column a list of the values that were collapsed.
I know I can do results <- setDT(df)[, list(ALIAS=paste(ALIAS, collapse = '|')) , ENSEMBL]
, but then I lose the middle two cols.