Skip to content

sorting data

4 messages · nandan amar, jim holtman, John Sorkin

#
a <- a[order(a[[4]]),]
On Fri, Oct 28, 2011 at 10:01 AM, nandan amar <nandan.amar at gmail.com> wrote:

  
    
#
I am not sure (I can't test at the moment) but will this work?
sort(a[,4])


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)
I want to sort my following data set according to value in 4th column

 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348
 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826
 0 1 2 27468.0314985496 38.4400363878507 2300.05521684593
 0 1 3 27469.1130543141 40.7540672493746 2299.32564458085
 0 1 4 27442.3152643187 52.4342875797706 2277.18286686329
 0 1 5 27440.7923082136 54.8003481512783 2274.49112409585
.....

I tried following :
first i wanted just to sort 4th column
gives class as
$class
[1] "data.frame"

and
Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing =
decreasing)) :
  undefined columns selected

How can I sort the data according to value in 4th column and print
along
with other columns