2

I have the following data:

d <- data.table(c = c("ABC", "XYZ", "IJK"), i = c("102", "102", "103"), n = c(100, 100, 1) )
> d
     c   i   n
1: ABC 102 100
2: XYZ 102 100
3: IJK 103   1

and wish to arrive to the result:

res <- data.table(i = c("102", "103"), n = c(100, 1), c = c("ABC, XYZ", "IJK") )
> res
     i   n        c
1: 102 100 ABC, XYZ
2: 103   1      IJK

which transformed the information in column 'c' (the first column) into the values in the third column of res.

How can I do that?

Matt Dowle
  • 58,872
  • 22
  • 166
  • 224
Timothée HENRY
  • 14,294
  • 21
  • 96
  • 136

0 Answers0