Hi I am struggling in finding a way to sort columns in a matrix. Can anyone help me, please? Thanks a lot, David
On Wed, Jul 09, 2003 at 05:39:31PM +0200, David Andel wrote: Hi, if you want to sort in alphabical order the columns of the matrix you colud do this aaa <- aaa[,sort(colnames(aaa))] Is it what you want? HIH, Stefano> Hi > > I am struggling in finding a way to sort columns in a matrix. Can anyone help me, please? > > Thanks a lot, > David > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Alternatively, if you want to sort first on aaa$a and second on aaa$b, then try the following: aaa[order(aaa$a, aaa$b),] hope this helps. spencer graves Stefano Calza wrote:> On Wed, Jul 09, 2003 at 05:39:31PM +0200, David Andel wrote: > > Hi, > > if you want to sort in alphabical order the columns of the matrix you colud do this > > aaa <- aaa[,sort(colnames(aaa))] > > Is it what you want? > > HIH, > > Stefano > > >>Hi >> >>I am struggling in finding a way to sort columns in a matrix. Can anyone help me, please? >> >>Thanks a lot, >>David >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
On 9 Jul 2003, David Andel wrote:> Hi > > I am struggling in finding a way to sort columns in a matrix. Can anyone > help me, please?You probably want order(). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
On Wed, Jul 09, 2003 at 09:10:53AM -0700, Spencer Graves wrote: Of course! I guess I misunderstood the question! Stefano> Alternatively, if you want to sort first on aaa$a and second on aaa$b, > then try the following: > > aaa[order(aaa$a, aaa$b),] > > hope this helps. spencer graves > > Stefano Calza wrote: > >On Wed, Jul 09, 2003 at 05:39:31PM +0200, David Andel wrote: > > > >Hi, > > > >if you want to sort in alphabical order the columns of the matrix you > >colud do this > > > >aaa <- aaa[,sort(colnames(aaa))] > > > >Is it what you want? > > > >HIH, > > > >Stefano > > > > > >>Hi > >> > >>I am struggling in finding a way to sort columns in a matrix. Can anyone > >>help me, please? > >> > >>Thanks a lot, > >>David > >> > >>______________________________________________ > >>R-help at stat.math.ethz.ch mailing list > >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > > >______________________________________________ > >R-help at stat.math.ethz.ch mailing list > >https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
I think the question was ambiguous. Now he has answers to two different interpretations of the question. Spencer Graves Stefano Calza wrote:> On Wed, Jul 09, 2003 at 09:10:53AM -0700, Spencer Graves wrote: > > Of course! I guess I misunderstood the question! > > Stefano > > > >>Alternatively, if you want to sort first on aaa$a and second on aaa$b, >>then try the following: >> >>aaa[order(aaa$a, aaa$b),] >> >>hope this helps. spencer graves >> >>Stefano Calza wrote: >> >>>On Wed, Jul 09, 2003 at 05:39:31PM +0200, David Andel wrote: >>> >>>Hi, >>> >>>if you want to sort in alphabical order the columns of the matrix you >>>colud do this >>> >>>aaa <- aaa[,sort(colnames(aaa))] >>> >>>Is it what you want? >>> >>>HIH, >>> >>>Stefano >>> >>> >>> >>>>Hi >>>> >>>>I am struggling in finding a way to sort columns in a matrix. Can anyone >>>>help me, please? >>>> >>>>Thanks a lot, >>>>David >>>> >>>>______________________________________________ >>>>R-help at stat.math.ethz.ch mailing list >>>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help >>> >>> >>>______________________________________________ >>>R-help at stat.math.ethz.ch mailing list >>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help