[R] efficient list indexing

2010-09-22 Thread Alaios
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

Re: [R] efficient list indexing

2010-09-22 Thread Patrick Burns
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

Re: [R] efficient list indexing

2010-09-22 Thread Keith Jewell
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

Re: [R] efficient list indexing

2010-09-22 Thread Dennis Murphy
Hi: I believe we had this discussion yesterday, http://r.789695.n4.nabble.com/Object-oriented-programming-in-R-td2538541.html#a2538916 but since you chose to repeat that message, it clearly wasn't enough, so start with http://cran.r-project.org/doc/manuals/R-intro.html#Lists

Re: [R] efficient list indexing

2010-09-22 Thread Alaios
Great one! Thanks this will simplify a lot addresing. Best REgards From: Keith Jewell k.jew...@campden.co.uk To: r-h...@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

Re: [R] efficient list indexing

2010-09-22 Thread Alaios
For some reason I did not receive your email. Sorry for the inconvenience caused From: Dennis Murphy djmu...@gmail.com Cc: Rhelp r-help@r-project.org Sent: Wed, September 22, 2010 1:46:28 PM Subject: Re: [R] efficient list indexing Hi: I believe we had