But converting to POSIXct I need to supply an origin something like
1970-01-01 which is weird and unintuitive...

And what if I am not dealing with xts/zoo objects?

For example,


ss=tt[with(tt, order(DateTimeStamps)),]


where "tt" is a data.frame read from csv file.

My goal was to order the rows of the data.frame based on the DateTimeStamps
(in the previously discussed formatting)... I found the tt$DateTimeStamps
is actually "factor" ...

So my question is: ordering them like the one I did above,

is it correct?

Thanks a lot!




On Fri, Jan 20, 2012 at 10:44 AM, R. Michael Weylandt <
michael.weylandt@gmail.com> wrote:

> I can't immediately come up with an counter-example where lexical
> ordering and calendar ordering are different if you have a consistent
> amount of digits, but wouldn't it just be easier (and more
> computationally efficient) to convert your character to a POSIXct
> before doing the comparison?
>
> Or (if you actually read the xts documentation!) there's a (much) better
> trick:
>
> ? `[.xts`
> tmp1["::20110920 12:01:33.386168"]
>
> Michael Weylandt
>
> On Fri, Jan 20, 2012 at 11:32 AM, Michael <comtech.usa@gmail.com> wrote:
> > These are char strings:
> > "2011-09-20 12:01:33.386168"
> > In fact,
> > I want to do subsetting of xts objects:
> > lets say tmp1 is an xts object:
> > tmp2 = tmp1[index(tmp1)< "2011-09-20 12:01:33.386168"]
> > Will it work?
> > Thanks again!
> >
> > On Fri, Jan 20, 2012 at 10:02 AM, Brian G. Peterson <brian@braverock.com
> >wrote:
> >
> >> On Fri, 2012-01-20 at 09:49 -0600, Michael wrote:
> >> > Good morning all!
> >> >
> >> > Just wanted to confirm - how do I compare two date-time stamps in the
> >> > following format?
> >>
> >> > > "2011-09-20 12:01:33.386168"< "2011-09-20 12:01:33.386169"
> >> >
> >> > [1] TRUE
> >>
> >> You don't tell us what class those timestamps are.
> >>
> >> Assuming you're using xts objects for your time series (which you should
> >> be), then the index is POSIXct, and < > = , etc are defined for the
> >> POSIXct class.
> >>
> >> It won't care about the string format.
> >>
> >> --
> >> Brian G. Peterson
> >> http://braverock.com/brian/
> >> Ph: 773-459-4973
> >> IM: bgpbraverock
> >>
> >>
> >
>  >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-SIG-Finance@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> > -- Subscriber-posting only. If you want to post, subscribe first.
> > -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]

