[R] Sorting a matrix by a column

John Sorkin jsorkin at grecc.umaryland.edu
Mon Aug 4 20:48:48 CEST 2008


R 2.6
Windows XP

I have a 100x4 matirx

data<-matrix(nrow=100,ncol=4)

I would like to sort the entire matrix by column two, i.e. data[,2]
I looked at the help page for sort() but can not determine how I can use it to sort a matrix on one of the matrix's columns.

Thanks,
John 

John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}



More information about the R-help mailing list