s-news
[Top] [All Lists]

Summary: How do I extract the index of the max (or min) of a vector?

To: S-News <s-news@wubios.wustl.edu>
Subject: Summary: How do I extract the index of the max (or min) of a vector?
From: Kim Elmore <Kim.Elmore@noaa.gov>
Date: Wed, 31 Oct 2007 11:59:38 -0500
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)
Thanks to all who replied. I knew this was easy and that I'm simply having a slow day.

Due to a failure to update a shortcut, I couldn't find the functions which.max() and which.min() because I was in S-Plus 7, where they are not. These appear in S-Plus 8.

However, in previous versions of S-Plus (back to at least 6), it's easy enough to do:

for the vector x, which(x == max(x)) works nicely.

Kim Elmore

<Prev in Thread] Current Thread [Next in Thread>
  • Summary: How do I extract the index of the max (or min) of a vector?, Kim Elmore <=