[R] location of maximum
laurent at genome.cbs.dtu.dk
Tue Mar 5 19:22:35 CET 2002
x <- rnorm(100)
mx <- max(x)
exact.location <- which(x == mx)
Hopin' it helps,
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
On Tue, 5 Mar 2002, Patrick Buetzberger wrote:
> 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.
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
More information about the R-help