Re: [R] To transform an adjacency matrix

2013-11-20 Thread Arnaud Michel
Thank you also for your help Michel Le 20/11/2013 19:04, Dennis Murphy a écrit : Hi: which(m == 1L, arr.ind = TRUE) Dennis On Wed, Nov 20, 2013 at 2:28 AM, Arnaud Michel 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.f

Re: [R] To transform an adjacency matrix

2013-11-20 Thread David Carlson
> indx <- arrayInd(which(m>0), .dim=c(5, 5)) > indx [,1] [,2] [1,]41 [2,]23 [3,]43 [4,]24 [5,]15 # If you want the result sorted > indx[order(indx[,1], indx[,2]),] [,1] [,2] [1,]15 [2,]23 [3,]24 [4,]41 [5,]43

Re: [R] To transform an adjacency matrix

2013-11-20 Thread Arnaud Michel
Thank you Pascal Its fine Michel Le 20/11/2013 11:55, Pascal Oettli a écrit : Hello, One approach is: 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)) out <- which(m==1, arr.ind=TRUE) out[order(out[,1]),] Regards, Pascal On 20 Nove

Re: [R] To transform an adjacency matrix

2013-11-20 Thread Pascal Oettli
Hello, One approach is: 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)) out <- which(m==1, arr.ind=TRUE) out[order(out[,1]),] Regards, Pascal On 20 November 2013 19:28, Arnaud Michel wrote: > Hi > I have the following problem > I w