[R] how to sort columns in a matrix?

Spencer Graves spencer.graves at pdf.com
Wed Jul 9 18:10:53 CEST 2003


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




More information about the R-help mailing list