Re: [Rd] arr.ind argument to which.min and which.max

From: Martin Maechler <>
Date: Mon, 05 Jul 2010 11:56:58 +0200

>>>>> "PatB" == Patrick Burns <>
>>>>> on Sun, 04 Jul 2010 09:43:44 +0100 writes:

    PatB> Is there a reason that 'which.min' and
    PatB> 'which.max' don't have an 'arr.ind'
    PatB> argument?

well, help(which.min) tells you that they really were aimed at doing their job *fast* for vectors.

Of course you are right and a generalization to arrays might be convenient at times.

    PatB> The context in which I wanted that was
    PatB> a grid search optimization, which seems
    PatB> like it would be reasonably common to me.

well, as the author of these two functions, I can only say

      "patches are welcome!"

and I think should be pretty simple, right ? You just have to do very simple remapping of the 1d index 'i' back to the array index, i.e., the same operation you need to transform seconds into days:hours:minutes:seconds {{and yes, we old-timers may recall that APL had an operator (I   think "T-bar") to do that ...}

Martin Maechler, ETH Zurich

    PatB> -- 
    PatB> Patrick Burns
    PatB> (home of 'Some hints for the R beginner'
    PatB> and 'The R Inferno')

______________________________________________ mailing list Received on Mon 05 Jul 2010 - 11:16:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 06 Jul 2010 - 19:40:12 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive