It might be an easy question but how to construct correctly a list in a loop? 

The following doesn't work
before starting the loopd = NULL#in the loop, 1st iteration
d = list(d,c(1,2,3)d[[1]]
NULL

[[2]]
[1] 1 2 3#in the loop, 2nd iterationd=list(d,c(4,5,6)d
[[1]]
[[1]][[1]]
NULL

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


[[2]]
[1] 4 5 6
the goal is to have the result of d= list(c(1,2,3),c(4,5,6)) where the list 
components are not known out of the loop.
d[[1]]
[1] 1 2 3

[[2]]
[1] 4 5 6
Moreover, how to name the components of the list in the loop while constructing 
as the names are not known out of the loop, either? note that the name of the 
component is stored in a variable in the loop

d = NULL#name1 contains the name for c(1,2,3), how to give the name below?
d = list(d,c(1,2,3)
Thanks
 
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to