Thank you guys! I got it.
Best,
Feng
- Original Message -
From: Benilton Carvalho [EMAIL PROTECTED]
To: Feng Qiu [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Thursday, January 18, 2007 12:20 AM
Subject: Re: [R] how to get the index of entry with max value in an array?
Hi all:
A short question:
For example, a=[3,4,6,2,3], obviously the 3rd entry of the array has
the maxium value, what I want is index of the maxium value: 3. is there a neat
expression to get this index?
Thank you!
Best,
Feng
[[alternative HTML version deleted]]
In R language, one solution is:
a-c(3,4,6,2,3)
which(a==max(a))
On 1/18/07, Feng Qiu [EMAIL PROTECTED] wrote:
Hi all:
A short question:
For example, a=[3,4,6,2,3], obviously the 3rd entry of the array
has the maxium value, what I want is index of the maxium value: 3. is
Or
which.max(a)
-Christos
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of talepanda
Sent: Wednesday, January 17, 2007 11:45 PM
To: Feng Qiu
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] how to get the index of entry with max value in an array?
In R
?which.max
?which.is.min
On Wed, 17 Jan 2007, Feng Qiu wrote:
Hi all:
A short question:
For example, a=[3,4,6,2,3], obviously the 3rd entry of the array has
the maxium value, what I want is index of the maxium value: 3. is there a
neat expression to get this index?
which.max
a - sample(1:10,10)
a
[1] 3 4 5 7 2 8 9 6 10 1
which.max(a)
[1] 9
On 1/17/07, Feng Qiu [EMAIL PROTECTED] wrote:
Hi all:
A short question:
For example, a=[3,4,6,2,3], obviously the 3rd entry of the array
has the maxium value, what I want is index of
which.max()
b
On Jan 17, 2007, at 11:20 PM, Feng Qiu wrote:
Hi all:
A short question:
For example, a=[3,4,6,2,3], obviously the 3rd entry of
the array has the maxium value, what I want is index of the maxium
value: 3. is there a neat expression to get this index?