Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
and in addition to bill's suggestion, you may want to consider not growing a list. Instead of 'v <- list()', use: v <- vector("list", nrow(A)) b > Will your code work as you wish if you > replace the "for(v[[1]] in x[[1]]) { ... }" > with the following? >   for(i in x[[1]]) { >      v[[2]] <- i

Re: [R] using a list to index elements of a list

2010-03-23 Thread Pj253
Thanks Bill, that sorted it out! And thank you too Ben! Bill and Ben. Are you familiar with the flowerpot men by any chance!? Thanks again! -- View this message in context: http://n4.nabble.com/using-a-list-to-index-elements-of-a-list-tp1679184p1679293.html Sent from the R help mailing list a

Re: [R] using a list to index elements of a list

2010-03-23 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Pj253 > Sent: Tuesday, March 23, 2010 7:54 AM > To: r-help@r-project.org > Subject: [R] using a list to index elements of a list > > > I have a list of vectors, x, with x[[1]]=1

Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
can you also post an example of A and an example of the expected result? On Tue, Mar 23, 2010 at 3:36 PM, Pj253 wrote: > > Thanks for your reply Ben! > > I don't think I want v to be identical to x... I guess I haven't put the > question in the right context. What I'm actually trying to do is...

Re: [R] using a list to index elements of a list

2010-03-23 Thread Pj253
Thanks for your reply Ben! I don't think I want v to be identical to x... I guess I haven't put the question in the right context. What I'm actually trying to do is... (* indicates extra information, not necessarily relevant for my question, but to help put it in context) A, some matrix (*a tra

Re: [R] using a list to index elements of a list

2010-03-23 Thread Benilton Carvalho
if this was to work, wouldn't the object 'v' be identical to 'x'?... so, why not use 'x' itself? b On Tue, Mar 23, 2010 at 2:53 PM, Pj253 wrote: > > I have a list of vectors, x, with x[[1]]=1:5, say. > > And I need to go through each element of each vector in a for loop. > Something like: > > for