On 11-01-2013, at 18:55, eliza botto <eliza_bo...@hotmail.com> wrote:

> 
> Dear useRs,
> I have a very basic question. I have a distance matrix and i skipped the 
> upper part of it deliberately. The distance matrix is 1000*1000.  Then i used 
> "min" command to extract the lowest value from that matrix. Now i want to 
> know what is the location of that lowest element? More precisely, the row and 
> column number of that lowest element. 

If you had looked at the help of min you could have seen that which.min could 
be useful.

?which.min

and from See also

?arrayInd

so this will do it

mat <- matrix(runif(25),nrow=5)
arrayInd(which.min(mat),.dim=dim(mat))

Berend
______________________________________________
R-help@r-project.org 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.

Reply via email to