[R] list: index of the element, that is TRUE
R. Michael Weylandt
michael.weylandt at gmail.com
Mon Jan 16 16:43:00 CET 2012
I'd just unlist it to a vector and use the same methods: a plus of
this (I believe) is that if you get a vector when a list as expected,
your program will continue to work.
Michael
On Mon, Jan 16, 2012 at 10:34 AM, Marion Wenty <marion.wenty at gmail.com> wrote:
> Dear People,
>
> I have got the following example for a vector and the index of the TRUE
> element:
>
> Myvector <- c(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
> which(Myvector)
>
> Now I would like to find out the same for a list:
>
> Mylist <- list(FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE)
>
> ...
>
> Does anyone know how to do this?
>
> Thank you very much in advance,
> Marion
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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