[R] index of max value ?

Spencer Graves spencer.graves at pdf.com
Fri Nov 14 20:56:27 CET 2003


Have you considered: 

 > x <- c(1, 3, 1)
 > which(x==max(x))
[1] 2

Is this what you want?  spencer graves

ryszard.czerminski at pharma.novartis.com wrote:

>Is there a function in R, which would return index of maximum value
>in a vector ?
>
>e.g.
>
>  
>
>>v <- round(10*rnorm(8))
>>v
>>    
>>
>[1]   6  -3  -6  15   7   9   0 -19
>  
>
>>max(v)
>>    
>>
>[1] 15
>
>??? index.max(v)
>??? 4
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>  
>




More information about the R-help mailing list