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

Was it helpful?

Solution

Try this:

lst <- list(dfB, dfC, dfD)
result <- dfA
for (df in lst) result <- merge(result,df,by="ID")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top