[R] ordering a vector

Francesco Petrogalli francesco.petrogalli at gmail.com
Fri Jan 21 20:38:42 CET 2011


Hi,
is there a R function that order a matrix according to some criteria
based on the rows(or cols) of that matrix?

For example, let's say that my matrix S is composed by n rows S_1,
S_2,.., S_n and that I compute some real value g_i=g(S_i) for each
row.
Then I want to order this set of g_i (from smaller to bigger) and
order the correspondent row to the new position.

Is it possible (apart from looping on the index) to do this with some
predefined R function?

Thanks,

Francesco



More information about the R-help mailing list