[R-SIG-Finance] Problems extracting xts data in my own time zone

Albert Nigrin anigrin at gmail.com
Fri Nov 7 05:07:22 CET 2008


I'm having problems extracting data using the powerful subsetting features
of xts. I am using R 2.8 with the latest version of zoo and xts on Windows
XP 64.  I live near Washington DC so my local timezone is EDT.  My problem
is that when I enter a character string to get a subset from an xts time
series, the time/date is interpreted to be in GMT rather than Eastern
Standard time.

This is easily illustrated with an example

Sys.getenv("TZ")
TZ 
"" 
> x = xts(1:3, Sys.time() - 1:3)
> x
2008-11-06 22:39:39 2008-11-06 22:39:40 2008-11-06 22:39:41 
                  3                   2                   1 

> index(x)
[1] "2008-11-06 22:39:39 EST" "2008-11-06 22:39:40 EST" "2008-11-06 22:39:41
EST"

> x["2008-11-06 22:39"]
      
> x["2008-11-07 03:39"]
                     
2008-11-06 22:39:39 3
2008-11-06 22:39:40 2
2008-11-06 22:39:41 1

Thus, when I try to extract data using my local time zone, nothing is
returned.  However when I Use GMT, the proper data is returned. How can I
extract data using my local time zone, instead of having to mentally convert
to GMT?

Thanks
Albert



More information about the R-SIG-Finance mailing list