From pburns at pburns.seanet.com  Tue Jul  6 12:34:27 2010
From: pburns at pburns.seanet.com (Patrick Burns)
Date: Tue, 06 Jul 2010 11:34:27 +0100
Subject: [Rd] arr.ind argument to which.min and which.max
In-Reply-To: <19506.64816.96176.185437@lynne.math.ethz.ch>
References: <4C3049C0.60101@pburns.seanet.com>	<19505.44138.313406.770145@lynne.math.ethz.ch>	<4C322408.3060206@pburns.seanet.com>	<AANLkTil28yqzrVns5iUmgd7Ni1RpnjHTOQ-Q4YVqFiiz@mail.gmail.com>	<AANLkTik9VdisM61U80y5Eb4dDhgHWgwBkEpjB_ixFWtZ@mail.gmail.com>
	<19506.64816.96176.185437@lynne.math.ethz.ch>
Message-ID: <4C3306B3.3010200@pburns.seanet.com>

On 06/07/2010 10:53, Martin Maechler wrote:

[ ... ]

>
> Wouldn't it make more sense to call
>
>     arrayInd(which.min(mat), dim(mat))
>
> instead of
> 	    which.min(mat, arr.ind = TRUE)
>
> in the spirit of modularity, maintainability, ... ?
> Honestly, in my first reply I had forgotten about my own
> arrayInd() modularization....

Yes.  Then I guess the suggested change is to
put 'arrayInd' in the See Also and Examples for
'which.min' for dunderheads like me that don't
think of it themselves.

>
>      >>>  If the order of the if condition were reversed, then
>      >>>  possibly the slight reduction in speed of 'which.min'
>      >>>  and 'which.max' would be more than made up for in the
>      >>>  slight increase in speed of 'which'.
>
> thanks for the hint, but
>
>        "increase in speed of 'which'"  -- really, can you measure that?

I doubt it.

>
> (I'll reverse the order anyway)
>
> If we are interested in speed increase, we should add an option
> to *not* work with dimnames at all (*) and if we have programmer
> time left, we could take it .Internal() and get a real
> boost... not now though.
>
> (*) I'm doing that for now, *and* I would like to change the
>      default behavior or arrayInd(), but of course *not* the
>      default behavior of which(),
>      to *not* attach dimnames to the result, by default.
>
>    I.e., I'm proposing to add   'useNames = FALSE' as argument to
>    arrayInd() but have  which() call arrayInd(..., useNames=TRUE).
>
>    This is a back-compatibility change in arrayInd() -- which has
>    existed only since 2.11.0 anyway, so would seem ok, to me.
>
>    Opinions ?

I find it hard to believe that would cause
too much trauma.

Pat

>
> --
> Martin
>

-- 
Patrick Burns
pburns at pburns.seanet.com
http://www.burns-stat.com
(home of 'Some hints for the R beginner'
and 'The R Inferno')



[Rd] arr.ind argument to which.min and which.max
Patrick Burns