This is a bit hard to describe, so I would like to give an example.
Assume we have the following data.table: X, Y, Z are the attributes' names, and Y is column of factors, Z is a column of numerics
X Y Z
1 A 0.75
1 B 0.25
2 C 1
3 A 0.25
3 B 0.25
3 C 0.5
we would like to change the above table to the following (if there is no corresponding value, we just use 0):
X A B C
1 0.75 0.25 0
2 0 0 1
3 0.25 0.25 0.5
So is there any function provided in data.table to handle this? or can anyone tell me how to do this efficiently?