Re: [R] Get the location of a numeric element in a list

2016-06-28 Thread Mohammad Tanvir Ahamed via R-help
Thanks Martin Morgan. Thats works excellent on a large data . Tanvir Ahamed Göteborg, Sweden | mashra...@yahoo.com - Original Message - From: Martin Morgan To: Mohammad Tanvir Ahamed ; R-help Mailing List Sent: Tuesday, 28 June 2016, 11:07 Subject: Re: [R] Get the location of a

Re: [R] Get the location of a numeric element in a list

2016-06-28 Thread Martin Morgan
On 06/28/2016 03:03 AM, Mohammad Tanvir Ahamed via R-help wrote: Can any one please help me. I will apply this for a very large list, about 400k vector in a list and vector size is unequal and large Example : Input: a <- c(1,3,6,9,25,100) b<-c(10,7,20,2,25) c<-c(1,7,5,15,25,300,1000) d<-list(a,

Re: [R] Get the location of a numeric element in a list

2016-06-28 Thread PIKAL Petr
Hi This could give you desired result, however I am not sure about performance or elegancy. which(sapply((lapply(d, "==", 1)), any)) Or you can transform it to a function fff <- function(x,a) which(sapply((lapply(x, "==", a)), any)) > fff(d, 25) [1] 1 2 3 > fff(d, 5) [1] 3 > fff(d, 1) [1] 1 3

Re: [R] Get the location of a numeric element in a list

2016-06-28 Thread Jim Lemon
Hi Tanvir, How about this: value<-1 (1:length(d))[unlist(lapply(lapply(d,"==",value),any))] Jim On Tue, Jun 28, 2016 at 5:03 PM, Mohammad Tanvir Ahamed via R-help wrote: > Can any one please help me. I will apply this for a very large list, about > 400k vector in a list and vector size is une