Try this:
lst <- list(dfB, dfC, dfD)
result <- dfA
for (df in lst) result <- merge(result,df,by="ID")
Question
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
Solution
Try this:
lst <- list(dfB, dfC, dfD)
result <- dfA
for (df in lst) result <- merge(result,df,by="ID")