Grokbase Groups R r-help March 2002
FAQ

Patrick Buetzberger <patrick@giub.unibe.ch> writes:

Dear R-users,

I'm trying to extract the exact location of the maximum value in a
vector or a matrix, meaning I want not only the maximum itself but also
at which position (e.g row 6, column 12) it is located.
I appreciate any suggestions.
To find which element of x is equal to the maximum of x, try

which(x==max(x))

if you want the array index of the maximum of a matrix, use

which(m==max(m), arr.ind=TRUE)

--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 4 | next ›
Discussion Overview
groupr-help @
categoriesr
postedMar 5, '02 at 2:49p
activeMar 5, '02 at 6:35p
posts4
users4
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase