Reputation: 496
If in this code I merge 2 data frames by ID,
full <- merge(data frameA,data frameB,by="ID")
How can I merge 4 data frames by the same ID avoiding using this code several times?
Thanks
Upvotes: 3
Views: 141
Reputation: 59425
Try this:
lst <- list(dfB, dfC, dfD)
result <- dfA
for (df in lst) result <- merge(result,df,by="ID")
Upvotes: 3