Message-ID: <CAAxdm-5RMZcwMEO16+nrcBKMY+y+D4TWAAopPq9u8X8tYrNRNA@mail.gmail.com>
Date: 2011-10-28T14:08:43Z
From: jim holtman
Subject: sorting data
In-Reply-To: <CAExv3aJt_-FueGFx2uPVvuwmcK6=aB3LWgmNtwgTFC5vQ=qGxQ@mail.gmail.com>
a <- a[order(a[[4]]),]
On Fri, Oct 28, 2011 at 10:01 AM, nandan amar <nandan.amar at gmail.com> wrote:
> 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
> ?:nandan.amar at gmail.com
> http://aknandan.co.nr
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?