Great one!
Thanks this will simplify a lot addresing.
Best REgards




________________________________
From: Keith Jewell <k.jewell@campden.co.uk>
To: r-help@stat.math.ethz.ch
Sent: Wed, September 22, 2010 1:25:27 PM
Subject: Re: [R] efficient list indexing

Also, it may be that you want bigfred to be a list of 5 lists each of 2 
elements (happy and name) rather than a list of 10 elements.

Thus (also using double bracketing)

fred<- list(happy = 1:10, name = "squash")
bigfred <- replicate(5, fred, FALSE)
bigfred[[2]][[2]]

hth

Keith J

"Patrick Burns" <pburns@pburns.seanet.com> wrote in message 
news:4C99E118.2010805@pburns.seanet.com...
> I'm confused by what you are looking for.
> There's some slight possibility that you
> are looking for double bracket subscripting
> with a vector:
>
> > list(a=1:5, b=letters)[[c(2,4)]]
> [1] "d"
>
>
> On 22/09/2010 10:58, Alaios wrote:
>> Hello everyone,
>>
>> I need some help with lists inside lists (a good way to emulate a 
>> struct)\
>>
>> Assume that there is a small list called fred:
>> fred<- list(happy = 1:10, name = "squash")
>>
>>
>> and a big list called bigfred that includes fred list 5 times
>> bigfred<- rep(fred,5)
>>
>> Is it possible somehow to index all these sublists(fred) inside bigfred 
>> with a
>> more direct way like this:
>> bigfred[1] shows the first sublist fred
>> bigfred[2][2] shows the second sublist fred, the second element of the 
>> fred list
>>
>> So far I found some way to do this by refering to the sublists by the 
>> following:
>> bigfred[1+index*length(fred)]
>> where index shows the beginning of a sublist.
>>
>> I would like to thank you in advance for your help
>> Best Regards
>> Alex
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help@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.
>>
>
> -- 
> Patrick Burns
> pburns@pburns.seanet.com
> http://www.burns-stat.com
> (home of 'Some hints for the R beginner'
> and 'The R Inferno')
>

______________________________________________
R-help@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.



      
	[[alternative HTML version deleted]]

