Command Reference : Function Reference : Function Reference: C
  
 
@capplyranks
Reorder the rows of a matrix using a vector of ranks.
Syntax: @capplyranks(m, v[, n])
m: matrix, vector
v: vector
n: (optional) integer
Return: matrix, vector
Apply (a column of) row ranks in the vector v to reorder the rows of a matrix m using the ranks.
v should contain unique integers from 1 to the number of rows of m.
If the optional argument n is specified, only the elements in column n will be reordered.
Examples
matrix m1 = @mnrnd(10, 4)
vector v1 = @ranks(m1.@col(4), "a", "i")
matrix m2 = @capplyranks(m1, v1)
reorders the rows of the matrix M1 using the ranks in V1. Note that you may use the @ranks function to obtain the ranks of a vector, but must obtain unique integer ranking for data with ties through use of the “i” or “r” option in @ranks.
matrix m3 = @capplyranks(m1, v1, 3)
reorders only the elements of column 3 of M1.
Cross-references
See also @sort, @colsort, and @rowsort.
See also @ranks, @colranks.
See also @rapplyranks.