Skip to content
Prev 366485 / 398502 Next

About populating a dataframe in a loop

Hello,

Works with me:

set.seed(6574)

pre.mat = data.frame()
for(i in 1:10){
     mat.temp = data.frame(x = rnorm(5), A = sample(LETTERS, 5, TRUE))
     pre.mat = rbind(pre.mat, mat.temp)
}

nrow(pre.mat)  # should be 50


Can you give us an example that doesn't work?

Rui Barradas

Em 06-01-2017 18:00, lily li escreveu: