[R] Sorting rows of a matrix independent of each other

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Mar 13 19:53:55 CET 2009


David Winsemius wrote:
>> Now I just need the resulting matrix:
>> 2 8 9
>> 4 6 7
>> 1 3 5
>
>
>
>
> On Mar 13, 2009, at 1:26 PM, Wacek Kusnierczyk wrote:
>
>> Kevski wrote:
>>> Oh, this seemed so simple (and I'm sure the answer will be, as
>>> usual, so
>>> thanks in advance for enlightening me). I need to sort each row of a
>>> matrix
>>> independent of the others. For example,
>>>
>>>
>>    apply(matrix, 1, sort)
>>
>>
>
>
> Actually this give the transpose of what was requested, since the
> results from apply come back as column vectors. 
ouch!!!  how ugly...

vQ




More information about the R-help mailing list