Dear R users,

I want to check matrices when i change the order of the rows or/and the order 
of the columns or/and the combination of them

i will give an example what i want

 1  -1  1  1      1  1   1  1

-1  -1 -1 -1    -1 -1  -1  -1

  1  1    1  1     1 -1    1   1

these 2 matrices are identical because i change the first row and make it third

  1  -1  1  1      -1  1   1  1

-1  -1 -1 -1    -1 -1  -1  -1

  1  1    1  1     1   1    1   1
these 2 matrices are identical because i change the first 2 columns
  1  -1  1  1      -1  -1   -1  -1

-1  -1 -1 -1       -1   1    1   1

  1  1    1  1       1   1    1   1
these 2 matrices are identical because i change the first 2 columns and the 
first two rows.

i wrote this two
combs.c <- combn(ncol(m1), 2)
    nc <- ncol(combs.c)
    ind.c <- vector("logical", nc)
    for (i in 1:nc) {
        m <- m1
        m[, combs.c[, i]] <- m[, rev(combs.c[, i])]
        ind.c[i] <- all(m == m2)
    }
    combs.r <- combn(nrow(m1), 2)
    nr <- ncol(combs.r)
    ind.r <- vector("logical", nr)
    for (i in 1:nr) {
        m <- m1
        m[combs.r[, i], ] <- m[rev(combs.r[, i]), ]
        ind.r[i] <- all(m == m2)
    }

for the first two

but i cant  make them work for the third
        [[alternative HTML version deleted]]

______________________________________________
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