Er, rbind is not merge... do.call expects the function you specify to handle
all the elements of the list in a single invocation... Reduce will work with a
two-argument function.
Reduce(merge, df.list, accumulate=TRUE, by='date')
For clarity: apply and the like have for loops inside them, so th
Short answer: do.call()
do.call("rbind", df.list)
will rbind all of the data frames in df.list.
You may have to tidy up row names afterwards, and you will need to make sure
that the data frames all have the same column names and each column has the
same class, or you'll get unexpected results.
> On 25 Jul 2018, at 08:17, Naresh Gurbuxani
> wrote:
>
> I have a list whose components are data frames. My goal is to construct a
> data frame by merging all the list components. Is it possible to achieve
> this using apply and without a for loop, as used below?
>
> Thanks,
> Naresh
>
3 matches
Mail list logo