You can grow them row by row by appending or using rbind()
.
That does not mean you should. Dynamically growing structures is one of the least efficient ways to code in R.
If you can, allocate your entire data.frame up front:
N <- 1e4 # total number of rows to preallocate--possibly an overestimate
DF <- data.frame(num=rep(NA, N), txt=rep("", N), # as many cols as you need
stringsAsFactors=FALSE) # you don't know levels yet
and then during your operations insert row at a time
DF[i, ] <- list(1.4, "foo")
That should work for arbitrary data.frame and be much more efficient. If you overshot N you can always shrink empty rows out at the end.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…