[R] Merging list of dataframes with reshape merge_all

Johannes Radinger johannesradinger at gmail.com
Fri Jan 11 11:08:19 CET 2013


Hi,

I'd like to merge mutliple dataframes from a list of dataframes by some common
columns. The approach for simply merging 2 dataframes is working with:

merge(df1,df2,by=c("col1","col2","col3"),all=TRUE)

For mutliple dataframes in a list I try to use the merge_all command
from the package reshape.
The documentation states that the command takes a list of dataframes
and other additional
argument which are passed on to merge. So I tried (just for the case
of two dataframes):

merge_all(list(df1,df2),by=c("col1","col2","col3"),all=TRUE)

but I get following error:
Error in merge.data.frame(dfs[[1]], dfs[[2]], all = TRUE, sort = FALSE,  :
  formal argument "all" matched by multiple actual arguments

What do I need to do to solve that problem?

PS: Just a related side-question: Why is merge_all not included in the
"newer" package reshape2 as this is considered to be a reboot of the
reshape package?

/johannes




More information about the R-help mailing list