[R] access an element of a list without looping

2014-07-03 Thread carol white
Hi, Is there any way to access an element of a list without looping over the list nor using unlist? Just to avoid parsing a very long list. For ex, how to find a vector of a length 2 in a list without using a loop? l = list (c(1), c(2,3), c(1,2,3)) for (i in 1:length(l))    

Re: [R] access an element of a list without looping

2014-07-03 Thread Greg Snow
You could use which( sapply(l, length) == 2 ) but that still uses a loop internally. On Thu, Jul 3, 2014 at 1:35 PM, carol white wht_...@yahoo.com wrote: Hi, Is there any way to access an element of a list without looping over the list nor using unlist? Just to avoid parsing a very long

Re: [R] access an element of a list without looping

2014-07-03 Thread Marc Schwartz
On Jul 3, 2014, at 2:35 PM, carol white wht_...@yahoo.com wrote: Hi, Is there any way to access an element of a list without looping over the list nor using unlist? Just to avoid parsing a very long list. For ex, how to find a vector of a length 2 in a list without using a loop? l =