Skip to content
Prev 200300 / 398503 Next

where is a value in my list

On Nov 15, 2009, at 10:01 AM, Grzes wrote:

            
I am a bit confused, since clearly lista[[1]][1] does _not_ == 5. It's  
also unclear what type of output you expect ... character, list,  
numeric?

See if these take you any further to your vaguely expressed goal:

 > lapply(lista, "%in%", 5)
[[1]]
[1] FALSE FALSE  TRUE  TRUE FALSE

[[2]]
[1] FALSE  TRUE FALSE FALSE

[[3]]
[1] FALSE FALSE FALSE FALSE

 > lapply(lista, function(x) which(x == 5) )
[[1]]
[1] 3 4

[[2]]
[1] 2

[[3]]
integer(0)
David Winsemius, MD
Heritage Laboratories
West Hartford, CT