[R] how to sort columns in a matrix?

Stefano Calza stecalza at tiscali.it
Wed Jul 9 18:43:18 CEST 2003


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




More information about the R-help mailing list