I have a for loop
which produces a data frame after each iteration. I want to append all data frames together but finding it difficult. Following is what I
am
Again maRtin is correct but for this to work you have start with a dataframe that already has at least one column
model <- #some processing
df <- data.frame(col1=model)
for (i in 2:17)
{
model <- # some processing
nextcol <- data.frame(model)
colnames(nextcol) <- c(paste("col", i, sep="")) # rename the comlum
df <- cbind(df, nextcol)
}
For me, it worked very simply. At first, I made an empty data.frame
, then in each iteration I added one column to it. Here is my code:
df <- data.frame(modelForOneIteration)
for(i in 1:10){
model <- # some processing
df[,i] = model
}