[R-SIG-Finance] Problems extracting xts data in my own time zone
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Nov 7 17:51:59 CET 2008
Do you really need time zones in the first place? If not you could
use chron and avoid the entire problem right from the start. See
R News 4/1.
On Thu, Nov 6, 2008 at 11:07 PM, Albert Nigrin <anigrin at gmail.com> wrote:
> 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
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
More information about the R-SIG-Finance
mailing list