Skip to content
Back to formatted view

Raw Message

Message-ID: <1319110370808-3921598.post@n4.nabble.com>
Date: 2011-10-20T11:32:50Z
From: ISMA11
Subject: locating minimum value in matrix
In-Reply-To: <B998A44C8986644EA8029CFE6396A9240100CE21@exqld2-bne.nexus.csiro.au>

Hi,

I was looking for a solution to the same problem. I just found something and
thought it might be useful to share.

Suppose you look for the positions of the minimum value in matrix D. Using a
little euclide division solves the problem easily. Here is my code.

min(D)
Dv=as.vector(D)
pos=which.min(Dv)
j0=floor(pos/nrow(D))+1
i0=pos%%nrow(D)
D[i0,j0] # must equal min(D)

Hope this is useful.

I.

--
View this message in context: http://r.789695.n4.nabble.com/locating-minimum-value-in-matrix-tp850619p3921598.html
Sent from the R help mailing list archive at Nabble.com.