Specifically, say I had three data frames d1, d2, d3
:
d1
:
X Y Z value
1 0 20 135 43
2 0 4 105 50
3 5 18 20 10
...
d2
:
X Y Z value
1 0 20 135 15
2 0 4 105 14
3 2 9 12 16
...
d3
:
X Y Z value
1 0 20 135 29
2 2 9 14 16
...
I want to be able to combine these data frames such that each row of the combined data frame consists of three values, based on all unique X, Y, Z combinations. If such an X, Y, Z combination does not exist in one of the original data frames then I just want it to have a value of null (or some arbitrarily low number if that isn't possible). So I'd want an output of:
dfinal
:
X Y Z value1 value2 value3
1 0 20 135 43 15 29
2 0 4 105 50 14 null
3 5 18 20 10 null null
4 2 9 12 null 16 null
5 2 9 14 null null 16
...
Is there any efficient way of doing this? I've tried doing this instead using data.table
which seemed more suited for this but have yet to figure out how.