[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)
which.max(x)


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: <croero at hotmail.com>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, April 04, 2007 5:13 PM
Subject: [R] argmax


Hello,

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

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

max(x)=15

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 
myself.
_________________________________________________________________

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