thanks. i think i understand: the difference is that the first command
converts my 'searched-for' date to a number and matches it, but the second
does not?

On 13 June 2012 12:58, Joshua Ulrich <josh.m.ulrich@gmail.com> wrote:

> On Tue, Jun 12, 2012 at 9:48 PM, Matthew Johnson <mcooganj@gmail.com>
> wrote:
> > Dear R experts,
> >
> > I am learning the very useful XTS package, but cannot figure out the
> > purpose of some commands.
> >
> > in particular, the .indexDate() command does not work as expected.
> >
> > say:
> >
> > x <- timeBasedSeq('2010-01-01/2010-01-02 12:00')
> > x <- xts(1:length(x), x)
> >
> > then i can subset on date as follows:
> >
> > x['2010-01-01']
> >
> > however the .indexDate() command does not work as expected; in
> > particular the following does not return anything.
> >
> > x[.indexDate(x) == '2010-01-01']
> >
> That's because all comparisons are FALSE.  .indexDate() returns the
> index of x, converted to the numeric representation of the Date class
> (i.e. as.Date(.indexDate(x), origin="1970-01-01") will be the Date of
> the index values).  '2010-01-01' is a character string.
>
> >
> > I am sure i am missing something - what is .indexDate() supposed to do?
> >
> Though it's not well documented, what it's doing is pretty clear from
> the source:
> R> .indexDate
> function (x)
> {
>    .index(x)%/%86400L
> }
> <environment: namespace:xts>
>
> >
> > thanks and best regards
> >
> >
> > matt johnson
> >
>
> Best,
> --
> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>

	[[alternative HTML version deleted]]

