[R] returning the largest element in an array/matrix?

Gabor Grothendieck ggrothendieck at gmail.com
Tue Mar 7 21:55:07 CET 2006


I agree that that is the best solution although not to the
question as stated which said: "I want to use which.max ...".

On 3/7/06, Michael <comtech.usa at gmail.com> wrote:
> I think this is the best solution! Thank you!
>
> On 3/7/06, Petr Pikal <petr.pikal at precheza.cz> wrote:
> >
> > Hi
> >
> > If you do not insist on which.max() you can use
> >
> > which(mat==max(mat), arr.ind=T)
> >
> > HTH
> > Petr
> >
> >
> >
> >
> > On 6 Mar 2006 at 20:55, Michael wrote:
> >
> > Date sent:              Mon, 6 Mar 2006 20:55:20 -0800
> > From:                   Michael <comtech.usa at gmail.com>
> > To:                     R-help at stat.math.ethz.ch
> > Subject:                [R] returning the largest element in an
> > array/matrix?
> >
> > > Hi all,
> > >
> > > I want to use "which.max" to identify the maximum in a 2D array/matrix
> > > and I want "argmin" and return the row and column indices.
> > >
> > > But "which.max" only works for vector...
> > >
> > > Is there any convinient way to solve this problem?
> > >
> > > Thanks a lot!
> > >
> > >  [[alternative HTML version deleted]]
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide!
> > > http://www.R-project.org/posting-guide.html
> >
> > Petr Pikal
> > petr.pikal at precheza.cz
> >
> >
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list