简体   繁体   English

在R中附加大量data.frame

[英]append a large number of data.frame in R

I have some unknown number of data frames that need to be glued together into a long single data frame. 我有一些数量未知的数据框,需要将它们粘在一起形成一个长的单个数据框。

set.seed(0)
N <- floor(rnorm(1,100,2))

for(i in 1:N){
  assign(paste('X', i, sep=''), data.frame(O=rnorm(1,100,2)))
}

Now I want to make a data frame with N rows and 1 column by combine the data frames X1 - XN together. 现在,我想通过将数据帧X1-XN组合在一起来制作一个N行1列的数据帧。

How can I do that? 我怎样才能做到这一点?

EDIT: 编辑:

Following Roland suggestions I switched to list: 根据罗兰(Roland)的建议,我切换到列表:

set.seed(0)
N <- floor(rnorm(1,100,2))


XP <- list()

for(i in 1:N){
  XP[[i]] <- data.frame(O=rnorm(1,100,2))
}   

I am still not sure about the next step.. 我仍然不确定下一步。

正如我在评论中已经说过的,您可以使用do.call ,它与@Roland的列表方法完美配合。

do.call(rbind,XP)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM