[R] where is a value in my list

Grzes gregorio99 at gmail.com
Sun Nov 15 16:01:28 CET 2009


I heve got a list: 

lista=list() 
a=c(2,4,5,5,6) 
b=c(3,5,4,2) 
c=c(1,1,1,8) 
lista[[1]]=a 
lista[[2]]=b 
lista[[3]]=c

 > lista 
[[1]] 
[1] 2 4 5 5 6 

[[2]] 
[1] 3 5 4 2 

[[3]] 
[1] 1 1 1 8 

I would like to know where is number 5 (which line)?

For example I have got a loop:

  k= vector(mode = "integer", length = 3)

 for(i in 1:3)
{
 for (j in 1:length(lista[[i]])){
if ((lista[[i]][j])==5   k[i]= [i])
}
}

This loop is wrong but I would like to get in my vector k sth like this:

k = lista[[1]][1], lista[[2]][1]     ...or sth similar
-- 
View this message in context: http://old.nabble.com/where-is-a-value-in-my-list-tp26359843p26359843.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list