Thanks to all, >a <- a[order(a[[4]]),] gives desired result >sort(a[,4]) sorts the data a[4]
regards,. On Fri, Oct 28, 2011 at 7:42 PM, John Sorkin <[email protected]>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) > > >>> nandan amar <[email protected]> 10/28/2011 10:01 AM >>> > 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 > >a<-read.tables("file_namr") > >attributes(a) > > gives class as > $class > [1] "data.frame" > > and > > > sort(a[4]) > 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 > -- > > Amar Kumar Nandan > Karnataka, India, 560100 > â:+91-9019054471 > â:[email protected] > http://aknandan.co.nr > > [[alternative HTML version deleted]] > > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:20}}
______________________________________________ [email protected] 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.

