QAMAR MUHAMMAD UZAIR
2012-Jun-01 01:54 UTC
[R] [urgent]arranging data in descending order in each column
Dear R users, I have data in the following manner [,1] [,2] [,3] [,4] 6 2 2 2 5 4 4 3 6 35 2 13 7 32 3 5 4 4 423 3 3 6 4 5 5 6 5 3 I want to arrange all the data in descending order. I have 92 columns in my actual data set. It is therefore difficult for me to apply order command to each column. Is there a short way of doing it? Thanks in advance..
Ben Bolker
2012-Jun-01 07:40 UTC
[R] [urgent]arranging data in descending order in each column
QAMAR MUHAMMAD UZAIR <d029307 <at> polito.it> writes:> > Dear R users, > > I have data in the following manner > > [,1] [,2] [,3] [,4] > 6 2 2 2 > 5 4 4 3[snip]> I want to arrange all the data in descending order. I have > 92 columns in my actual data set. It is therefore > difficult for me to apply order command to each column. Is > there a short way of doing it?Do you mean apply(mydata,2,sort,decreasing=TRUE) ?
QAMAR MUHAMMAD UZAIR
2012-Jun-01 09:16 UTC
[R] [urgent]arranging data in descending order in each column
Yes this is what i wanted. thanks indeed!!! On Fri, 1 Jun 2012 07:40:49 +0000 Ben Bolker <bbolker at gmail.com> wrote:> QAMAR MUHAMMAD UZAIR <d029307 <at> polito.it> writes: > >> >> Dear R users, >> >> I have data in the following manner >> >> [,1] [,2] [,3] [,4] >> 6 2 2 2 >> 5 4 4 3 > > [snip] > >> I want to arrange all the data in descending order. I >>have >> 92 columns in my actual data set. It is therefore >> difficult for me to apply order command to each column. >>Is >> there a short way of doing it? > > Do you mean > > apply(mydata,2,sort,decreasing=TRUE) > > ? > > ______________________________________________ > R-help at 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.