[R] Odp: how to extract the maximum from a matrix?

Petr PIKAL petr.pikal at precheza.cz
Fri Jun 1 11:52:30 CEST 2007


Hi

If you have tried to go through help pages of max you could find out which 
function, which can tell you position of your maximum.

which(x==max(x), arr.ind=T)

Regards

Petr Pikal
petr.pikal at precheza.cz

r-help-bounces at stat.math.ethz.ch napsal dne 01.06.2007 11:09:09:

> Dear UseRs,
> I have a very simple question. I have a big matrix (say x) including 
> probabilities (values in (0,1)).
> I have to store in a list the names of the row and the column where 
max(x) 
> is located. How can I proceed?
> 
> Thanks in advance for your assistance!
> 
> mirko
> 
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list