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

后端 未结 1 695
忘了有多久
忘了有多久 2021-01-07 01:44

Currently, i have multiple dataframes with the same name and in running order (foo1, foo2, foo3, foo4, foo5.

相关标签:
1条回答
  • 2021-01-07 02:09

    Always try to rigorously capture relations between related instances of data, or related data and methods, or related methods. This generally helps ease aggregate manipulation such as your rbind requirement.

    For your case, you should have defined your related data.frames as a single list from the beginning:

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

    And then your requirement could be satisfied thusly:

    do.call(rbind, foo );
    

    If it's too late for that, then the solution involving repeated calls to get(), as described in the article to which you linked, can do the job.

    0 讨论(0)
提交回复
热议问题