From Vincent.Goulet at act.ulaval.ca  Tue Jul  6 20:32:05 2010
From: Vincent.Goulet at act.ulaval.ca (Vincent Goulet)
Date: Tue, 6 Jul 2010 14:32:05 -0400
Subject: [Rd] arr.ind argument to which.min and which.max
In-Reply-To: <19505.44138.313406.770145@lynne.math.ethz.ch>
References: <4C3049C0.60101@pburns.seanet.com>
	<19505.44138.313406.770145@lynne.math.ethz.ch>
Message-ID: <999CB31F-0D0D-4D25-B939-E501CAB41A7A@act.ulaval.ca>

Le lun. 5 juil. ? 05:56, Martin Maechler a ?crit :

>>>>>> "PatB" == Patrick Burns <pburns at pburns.seanet.com>
>>>>>>    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 ...}

Ah, a reference to APL! That made my day. :-)

APL was very big among actuaries for a long time. I heard recently that it was still in use on an old system in some small insurance company. I still have on my shelves the reference books for APL*Plus III for Windows (that I ran in OS/2) from Magnugistics; they have an actuarial formula on the cover.

I teach my students arbitrary base conversion to do just what the encode/decode operators (to call them by their names) were doing. I see this new arrayInd() sort of does the same thing now. Darn, this steals me an exercise!

Cheers,

Vincent


> 
> Martin Maechler, ETH Zurich
> 
> 
>    PatB> -- 
>    PatB> Patrick Burns
>    PatB> pburns at pburns.seanet.com
>    PatB> http://www.burns-stat.com
>    PatB> (home of 'Some hints for the R beginner'
>    PatB> and 'The R Inferno')
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] arr.ind argument to which.min and which.max
Vincent Goulet