# how to extract the maximum from a matrix?

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## how to extract the maximum from a matrix?

 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 ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: how to extract the maximum from a matrix?

 look at the `arr.ind' argument of ?which(), e.g., x <- matrix(rnorm(9), 3, 3) x which(x == max(x), arr.ind = TRUE) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/     http://www.student.kuleuven.be/~m0390867/dimitris.htm----- Original Message ----- From: "mirko sanpietrucci" <[hidden email]> To: <[hidden email]> Sent: Friday, June 01, 2007 11:09 AM Subject: [R] how to extract the maximum from a matrix? > 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 > > ______________________________________________ > [hidden email] 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. > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.