[R] Sorting Posix Data

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Nov 26 18:26:54 CET 2001


On Mon, 26 Nov 2001, Prof Brian Ripley wrote:

> On Mon, 26 Nov 2001, Shawn Way wrote:
>
> > I have a fairly large set of data with the following attributes:
> >
> > >str(raw.data)
> > `data.frame':	1429 obs. of  16 variables:
> >  $ TStamp       :`POSIXlt', format: chr  "2001-11-25 02:00:00" "2001-11-25
> > 01:55:00" "2001-11-25 01:50:00" "2001-11-25 01:45:00" ...
> >  $ iPDT.AHU14.14: num  0.0122 0.0125 0.0120 0.0120 0.0122 ...
> >  $ iPDT.AHU14.15: num  0.0121 0.0123 0.0119 0.0119 0.0121 ...
> >  $ iPDT.AHU14.16: num  0.00635 0.00657 0.00608 0.00608 0.00631 ...
> >  $ iPDT.AHU14.17: num  0.0300 0.0304 0.0302 0.0300 0.0303 ...
> >  $ iPDT.AHU15.15: num  0.0986 0.0984 0.0980 0.0979 0.0983 ...
> >  $ iPDT.AHU15.16: num  0.0510 0.0521 0.0502 0.0507 0.0513 ...
> >  $ iPDT.AHU15.17: num  0.0665 0.0692 0.0683 0.0686 0.0674 ...
> >  $ PDT.AHU16.15 : num  0.0741 0.0753 0.0760 0.0747 0.0738 ...
> >  $ PDT.AHU16.16A: num  0.00152 0.00235 0.00167 0.00191 0.00172 ...
> >  $ PDT.AHU16.16B: num  0.0556 0.0563 0.0570 0.0560 0.0558 ...
> >  $ PDT.AHU16.17 : num  0.00883 0.00937 0.00877 0.00869 0.00873 ...
> >  $ PDT.AHU16.18 : num  0.141 0.142 0.142 0.144 0.141 ...
> >  $ PDT.AHU16.19 : num  0.0120 0.0123 0.0117 0.0116 0.0119 ...
> >  $ PDT.AHU16.20A: num  8.55e-06 1.55e-05 0.00e+00 2.36e-07 1.92e-06 ...
> >  $ PDT.AHU16.20B: num  0.0532 0.0536 0.0534 0.0532 0.0535 ...
> > >
> >
> > Unfortunately, the data is in the reverse order based on the date TStamp. Is
> > there any fairly easy method for reordering this set of data byt the first
> > column, a PosiX Date?
>
> o <- sort(as.POSIXct(raw.data$TStamp))
       ^^^^  I meant order
> raw.data[o, ]
>
> or if you really just want to reverse the order
>
> raw.data[nrow(raw.data):1, ]
>
> >
> >
> > "Don't rush me, you rush a miracle, you get a rotten miracle."
> > -Miracle Max, The Princess Bride
> >
> >
> > Shawn Way
> >
>
> --
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272860 (secr)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list