[R] find index in a list of list

Rui Barradas ruipbarradas at sapo.pt
Sat Mar 11 16:06:26 CET 2017


Hello,

Something like this?

find <- list(a=11,b="y")
which(sapply(mylist, identical, find))

Hope this helps,

Rui Barradas


Em 11-03-2017 14:59, ce escreveu:
> Hi all,
>
> I have a list of lists like this :
>
> mylist <- list(list(a=10,b="x"),list(a=11,b="y"),list(a=12,b="z"))
>
> I want to find the index of list in mylist where a = 11 and b  = "y"  , so I want to get 2 as a result
>
> Thanks in advance
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list