[R] Locate first index

Damon Wischik djw1005 at cam.ac.uk
Sun Sep 21 01:52:16 CEST 2003


>> I had noticed the remark on the help page, 
> 
> eehm, hardly possible, since I've only added it today to the
> development sources...
> You seem to be talking about something else, but related..

Indeed, I've been confusing myself thoroughly. I thought you were
referring to the remark that is there at the moment in R 1.7.0. And I
was confusing which.min and which.max too -- I was thinking of something
like
  x <- c(3,4,1,1,2,8,5)
  which.max(x>2.5)
which returns the first index where the condition is true. (This is a bad,
though: it returns 1 when the condition is never true.)

> Are you confusing  which.min() and "min.which" (which does not exist)?
> The non existing "min.which" is really the subject here, and
> it's the one where  match(a,x) can be used instead of
> min(which(a == x)).

Yes, I was confusing them -- via which.max. Sorry for confusing the issue!

Damon.




More information about the R-help mailing list