probably you need order(), e.g.,
data[order(data[, 2]), ]
I hope it helps.
Best,
Dimitris
John Sorkin wrote:
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 ...{{dropped:25}}
______________________________________________
R-help@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.