在 RI 中有这个矩阵
> a
id size pattern
[1,] "1" "24" "100"
[2,] "2" "10" "111"
[3,] "3" "2" "111"
我想按模式唯一,添加大小并连接 id:
> a
id size pattern
[1,] "1" "24" "100"
[2,] "2-3" "12" "111" (this pattern was duplicated, so add size and concatenate id)
我可以:
> a = unique(a[,"pattern"])
但我不知道如何添加和连接。
提前致谢!