Reputation: 793
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.
How can I do that?
EDIT:
Following Roland suggestions I switched to list:
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..
Upvotes: 1
Views: 175
Reputation: 6516
As I already said in the comments, you can use do.call
which works perfectly with the list approach from @Roland.
do.call(rbind,XP)
Upvotes: 3