Re: [R] Help on comparing two matrices

2009-08-25 Thread Michael Kogan
Gabor: Wow, that seems to be exactly what I need! Does it matter that "my" incidence matrices represent neighborhood relations between vertices and faces rather than between vertices and edges? Steve: Yep, I realize that this package is exactly what I'm searching for. :) Gabor Grothendieck s

Re: [R] Help on comparing two matrices

2009-08-25 Thread Steve Lianoglou
Hi, It looks like you're getting more good stuff, but just to follow up: On Aug 24, 2009, at 4:01 PM, Michael Kogan wrote: Steve: The two matrices I want to compare really are graph matrices, just not adjacency but incidence matrices. There should be a way to get an adjacency matrix of a gra

Re: [R] Help on comparing two matrices

2009-08-25 Thread Gabor Grothendieck
They can be regarded as incidence matrices rather than adjacency matrices and in that case it follows: library(igraph) # incidence matrix to canonical edge list inc2canel <- function(m) { g <- graph.incidence(m) cp <- canonical.permutation(g) can <- permute.vertices(g, cp$

Re: [R] Help on comparing two matrices

2009-08-25 Thread Michael Kogan
David: Ah, so that was the reason! I didn't realize that. :) Ok, so I try to go through the code and understand it: The last line seems to bring the rows into the order given by the "order" command. But how does the order command get the order? Lets look into the order function: the Reduce fun

Re: [R] Help on comparing two matrices

2009-08-24 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Michael Kogan > Sent: Saturday, August 22, 2009 11:45 AM > To: r-help@r-project.org > Subject: [R] Help on comparing two matrices > > Hi, > >

Re: [R] Help on comparing two matrices

2009-08-24 Thread David Winsemius
On Aug 24, 2009, at 4:01 PM, Michael Kogan wrote: David: Well, e.g. the first row has 2 ones in your output while there were no rows with 2 ones in the original matrix. Since the row and column sums can't be changed by sorting them, the output matrix can't be equivalent to the original one

Re: [R] Help on comparing two matrices

2009-08-24 Thread Michael Kogan
David: Well, e.g. the first row has 2 ones in your output while there were no rows with 2 ones in the original matrix. Since the row and column sums can't be changed by sorting them, the output matrix can't be equivalent to the original one. But that means nothing, maybe it's intended and just

Re: [R] Help on comparing two matrices

2009-08-23 Thread Steve Lianoglou
Hi, On Sun, Aug 23, 2009 at 4:14 PM, Michael Kogan wrote: > Thanks for all the replies! > > Steve: I don't know whether my suggestion is a good one. I'm quite new to > programming, have absolutely no experience and this was the only one I could > think of. :-) I'm not sure whether I'm able to put

Re: [R] Help on comparing two matrices

2009-08-23 Thread David Winsemius
On Aug 23, 2009, at 4:14 PM, Michael Kogan wrote: Thanks for all the replies! Steve: I don't know whether my suggestion is a good one. I'm quite new to programming, have absolutely no experience and this was the only one I could think of. :-) I'm not sure whether I'm able to put your tip

Re: [R] Help on comparing two matrices

2009-08-23 Thread Michael Kogan
Thanks for all the replies! Steve: I don't know whether my suggestion is a good one. I'm quite new to programming, have absolutely no experience and this was the only one I could think of. :-) I'm not sure whether I'm able to put your tips into practice, unfortunately I had no time for much re

Re: [R] Help on comparing two matrices

2009-08-22 Thread Gabor Grothendieck
On Sat, Aug 22, 2009 at 2:45 PM, Michael Kogan wrote: > Hi, > > I need to compare two matrices with each other. If you can get one of them > out of the other one by resorting the rows and/or the columns, then both of > them are equal, otherwise they're not. A matrix could look like this: >    [,1]

Re: [R] Help on comparing two matrices

2009-08-22 Thread Ted Harding
Steve, I don't know for sure whether this will help to solve your problem, but you may be interested to read about the algorithm devised by David Kendall for sorting 0-1 matrices, as described in Incidence matrices, interval graphs and seriation in archeology. Pacific J. Math. Volume 28, Num

Re: [R] Help on comparing two matrices

2009-08-22 Thread David Winsemius
On Aug 22, 2009, at 3:47 PM, David Winsemius wrote: On Aug 22, 2009, at 3:36 PM, Steve Lianoglou wrote: Hi, On Sat, Aug 22, 2009 at 2:45 PM, Michael Kogan wrote: Hi, I need to compare two matrices with each other. If you can get one of them out of the other one by resorting the rows

Re: [R] Help on comparing two matrices

2009-08-22 Thread David Winsemius
On Aug 22, 2009, at 3:36 PM, Steve Lianoglou wrote: Hi, On Sat, Aug 22, 2009 at 2:45 PM, Michael Kogan wrote: Hi, I need to compare two matrices with each other. If you can get one of them out of the other one by resorting the rows and/or the columns, then both of them are equal, ot

Re: [R] Help on comparing two matrices

2009-08-22 Thread Steve Lianoglou
On Sat, Aug 22, 2009 at 2:45 PM, Michael Kogan wrote: >> >> 1. Sort the rows after the row sums (greater sums first). >> 2. Sort the columns after the first column (columns with ones in the first >> row go left, columns with zeros go right). >> 3. Save the left part (all columns with ones in the

Re: [R] Help on comparing two matrices

2009-08-22 Thread Steve Lianoglou
Hi, On Sat, Aug 22, 2009 at 2:45 PM, Michael Kogan wrote: > Hi, > > I need to compare two matrices with each other. If you can get one of them > out of the other one by resorting the rows and/or the columns, then both of > them are equal, otherwise they're not. A matrix could look like this: > >

[R] Help on comparing two matrices

2009-08-22 Thread Michael Kogan
Hi, I need to compare two matrices with each other. If you can get one of them out of the other one by resorting the rows and/or the columns, then both of them are equal, otherwise they're not. A matrix could look like this: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,]011