[R] how do I find the row index number, or row name, of a given value in a vector?

John Kane jrkrideau at yahoo.ca
Sat Oct 21 18:03:36 CEST 2006


--- tom soyer <tom.soyer at gmail.com> wrote:

> Hi,
> 
> I noticed that max(x) returns the maximum value of a
> vector, but the
> function doesn't give the user the option of
> retrieving the row index number
> instead. If I used max(x) to find the maximum value
> of vector x, then is
> there a function I can use to find the index number,
> or row name, of the
> maximum value?
> 
> Thanks,
> 
> Tom
?which 

Is this what you want to do?  
xx <- c(1,2,3,4,9,6,7,5)
bb <- max(xx)
bb
which(xx==bb)



More information about the R-help mailing list