Skip to content
Prev 82106 / 398513 Next

Construct a data.frame in a FOR-loop

I think I know what you would like to have.

Sometyhing you can do
R> res<-vector("list",5)
R> for (i in 1:5)
R> {...
R>   res[[i]]=my_code(i)
R> }

As an easy example:
R> res<-vector("list",5)
R> for (i in 1:5){res[[i]]=1:i}
R> ex
[[1]]
[1] 1

[[2]]
[1] 1 2

[[3]]
[1] 1 2 3

[[4]]
[1] 1 2 3 4

[[5]]
[1] 1 2 3 4 5


Best regards,
Kristel