[R] ordering problem

Jose Luis Aznarte M. jlaznarte at decsai.ugr.es
Tue Sep 30 12:43:22 CEST 2008


        Hi there!
        I need some assistance here with vector orderings. I have a set 
of q vectors of length p, grouped by rows in a matrix A, q·p, that I 
need to order lexicographically 
(http://en.wikipedia.org/wiki/Lexicographical_order).
        I also have another matrix B, p·r, and a vector c, that should 
be ordered according to the order of A. So far, I was doing

    ordering <-  apply(A, 2, order)[,1]
    A <- A[ordering,]
    B <- B[ordering,]
    c <- c[ordering]

        But now I realize that this way I'm ordering by considering only 
the first dimension of the vectors in A, i.e., not considering the case 
where there are ties amongst this first dimension. Does anyone have a 
clue about properly applying the lexicographical ordering? Thanks in 
advance!

 
--                                                      --
Jose Luis Aznarte M.       http://decsai.ugr.es/~jlaznarte
Department of Computer Science and Artificial Intelligence
Universidad de Granada           Tel. +34 - 958 - 24 04 67
GRANADA (Spain)                  Fax: +34 - 958 - 24 00 79



More information about the R-help mailing list