[R] argmax

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Wed Apr 4 17:24:31 CEST 2007

check ?which.max(), e.g.,

x <- c(1,4,15,6,7)


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/

----- Original Message ----- 
From: <croero at hotmail.com>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, April 04, 2007 5:13 PM
Subject: [R] argmax


Is there any function that returns the argmax of a vector ?

For example I have the vector x=(1,4,15,6,7)


I want a function f such that f(x)=3 because this is where max(x) is.

Thank your very much.

P.S. : I know it is a basic question but I have not figured it out by 

ues clics pour retrouver tout ce qui vous intéresse au même endroit.

[[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
> and provide commented, minimal, self-contained, reproducible code.

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

More information about the R-help mailing list