I've searched for an answer to this simple question, but can't find a similar question. I have 3 data tables:
set.seed(0)
demo <- data.table(id = 1:10, demo.var = rnorm(10), key = 'id'); demo
lab <- data.table(id = 1:7, tc = rnorm(7), key = 'id'); lab
anthro <- data.table(id = 4:9, bmi = rnorm(6), key = 'id'); anthro
All IDs that are in lab and anthro are in the demo data.table, but lab and anthro contain different subsets of the IDs in demo
Both
lab[demo]
anthro[demo]
give the information I want: all 10 IDs with additional information from either the lab or anthro data.table, but is there a was to merge all 3 together in a similar manner? I've tried some permutations such as
anthro[lab][demo]
but this gives the preserves the anthro information only for the IDs that are in the lab data.table - there's no anthro information for IDs 8 and 9
Thanks in advance for any help