Hi List, I'm trying to work out how to use which(), or another function, to find the top-level index of a list item based on a condition. An example will clarify my question.
a <- list(c(1,2),c(3,4)) a [[1]] [1] 1 2 [[2]] [1] 3 4 I want to find the top level index of c(1,2), which should return 1 since; a[[1]] [1] 1 2 I can't seem to work out the syntax. I've tried; which(a == c(1,2)) and an error about coercing to double is returned. I can find the index of elements of a particular item by which(a[[1]]==c(1,2)) or which(a[[1]]==1) etc that return [1] 1 2 and [1] 1 respectively as they should. Any thoughts? C [[alternative HTML version deleted]] ______________________________________________ R-help@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.