On 14.05.2011 13:28, Alaios wrote:> Dear all,
> so far when I want to create a struct with a substructs I create.
> Lists with sublists by using functions and replicate.
>
> This will end up in to a struct that is addressed like that
>
> for (i in c(1:100){
> for (j in c(1:100){
> Mystruct[[1]][[2]][[1]][[i]][[k]]<-dosomething()
You can do it recursively using a vector of indices:
Mystruct[[c(1, 2, 1, i, k)]] <- dosomething()
in order to improve readability.
Uwe Ligges
> }
> }
> It is not hard for one to understand that this form for addressing
subfields of the struct [[1]][[2]][[1]]... and so on, make hard to track which
field of the strut you are addressing to. Even worse when I open my code after
one week I usually take some time to understand which field I wanted to address.
>
>
> Is there something more easier that I can do to face both these types of
problem?
>
> I would like to thank you in advance for your help
>
> Best Regards
> Alex
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.