in R I have this matrix
> a
id size pattern
[1,] "1" "24" "100"
[2,] "2" "10" "111"
[3,] "3" "2" "111"
and I want to unique by pattern, add the size and concatenate the id:
> a
id size pattern
[1,] "1" "24" "100"
[2,] "2-3" "12" "111" (this pattern was duplicated, so add size and concatenate id)
I can do:
> a = unique(a[,"pattern"])
but I couldn't figure out how to add and concatenate.
Thanks in advance!