[R] creating lists in a list with loop
"Häring, Tim (LWF)"
Tim.Haering at lwf.bayern.de
Fri Sep 4 15:01:45 CEST 2009
Hello !
I want to create a spatial stratified sampling scheme with the package spsurvey. To do this with the function "grts" in spsurvey, I need to create a list containing the specifications for each stratum. This specifications were stored in a named list, where the name for each stratum is the name for each list. This means, I need to create a "outer" list containing several "inner" lists.
> Stratdsgn <- list("Stratum1"=list(panel=c(Panel=6), seltype="Equal"),
+ "Stratum2"=list(panel=c(Panel=2), seltype="Equal"),
+ "Stratum3"=list(panel=c(Panel=4), seltype="Equal"))
> str(Stratdsgn)
List of 3
$ Stratum1:List of 2
..$ panel : Named num 6
.. ..- attr(*, "names")= chr "Panel"
..$ seltype: chr "Equal"
$ Stratum2:List of 2
..$ panel : Named num 2
.. ..- attr(*, "names")= chr "Panel"
..$ seltype: chr "Equal"
$ Stratum3:List of 2
..$ panel : Named num 4
.. ..- attr(*, "names")= chr "Panel"
..$ seltype: chr "Equal"
Because I do not have only 3 strata but 50 or more I would like to create this list with a for loop.
Could somebody help me to do this? I didn`t manged to create a list within a list in a loop.
Thanks for every hint.
TIM
More information about the R-help
mailing list