r - elegant way to use rbind() on multiple dataframes with similar names? -


currently, have multiple dataframes same name , in running order (foo1, foo2, foo3, foo4, foo5... etc). trying create large dataframe containing rows of above dataframes rbind(). there elegant way equivalent of rbind(foo1, foo2, foo3, foo4, foo5...)?

i have tried do.call(rbind, paste0("foo",i)) i=c(1,2,3...) no avail.

there solution mentioned here, is: do.matrix <- do.call(rbind, lapply( paste0("variable", 1:10) , get) )

however, answer mysteriously says "that wrong way handle related items. better use list or dataframe, find out why in due course."

why wrong way this, , "right" way?

thanks.

always try rigorously capture relations between related instances of data, or related data , methods, or related methods. helps ease aggregate manipulation such rbind requirement.

for case, should have defined related data.frames single list beginning:

foo <- list(data.frame(...), data.frame(...), ... ); 

and requirement satisfied thusly:

do.call(rbind, foo ); 

if it's late that, solution involving repeated calls get(), described in article linked, can job.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

Simple Angular 2 project fails 'Unexpected reserved word' -

ios - Possible to get UIButton sizeThatFits to work? -