Hi:
which(m == 1L, arr.ind = TRUE)
Dennis
On Wed, Nov 20, 2013 at 2:28 AM, Arnaud Michel <michel.arnaud at cirad.fr> wrote:
Hi
I have the following problem
I would like to build, from a matrix filled with 0 and with 1, a matrix
or a data.frame which contains, in every line, the number of the line
and the number of the column of the matrix for which the value is equal
to 1.
Exemple :
dput(m)
structure(c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1,
0, 0, 0, 1, 0, 0, 0, 0), .Dim = c(5L, 5L))
Result
1 5
2 3
2 4
4 1
4 3
Thank you for your help
--
Michel ARNAUD
Charg? de mission aupr?s du DRH
DGDRD-Drh - TA 174/04
Av Agropolis 34398 Montpellier cedex 5
tel : 04.67.61.75.38
fax : 04.67.61.57.87
port: 06.47.43.55.31
[[alternative HTML version deleted]]