[R-SIG-Finance] xts NA date for

Jeffrey Ryan jeffrey.ryan at lemnica.com
Fri Sep 23 14:44:37 CEST 2011


It is something within strptime and/or as.POSIXct.  Basically POSIXct
is causing some issue, somewhere.  In my TZ "America/Chicago" I see:

> strptime("04/05/87 2:00",format="%m/%d/%y %H:%M")
[1] "1987-04-05 02:00:00 CDT"
> as.POSIXct(strptime("04/05/87 2:00",format="%m/%d/%y %H:%M"))
[1] "1987-04-05 01:00:00 CST"
> as.POSIXct("04/05/87 2:00",format="%m/%d/%y %H:%M")
[1] "1987-04-05 01:00:00 CST"

Looks like a strange DST issue in the underlying R code.  I'll
continue to investigate.

> sessionInfo()
R version 2.13.1 RC (2011-07-04 r56273)
Platform: x86_64-apple-darwin10.7.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] xts_0.8-3 zoo_1.7-2

loaded via a namespace (and not attached):
[1] grid_2.13.1     lattice_0.19-17

Jeff

On Fri, Sep 23, 2011 at 7:38 AM, G See <gsee000 at gmail.com> wrote:
> hmmm.
>
> I'm using xts_0.8-3 revision 602 on R-Forge, and it *almost* works for me,
> but the time is off by an hour
>
>> xts(1, order.by=strptime("04/05/87 2:00",format="%m/%d/%y %H:%M"))
>                    [,1]
> 1987-04-05 01:00:00    1
>>
>
> -Garrett
>
> On Fri, Sep 23, 2011 at 7:33 AM, Dan Potter <arsanalytica at gmail.com> wrote:
>
>> Thank you Wolfgang.  On my machine sessionInfo shows I am using xts
>> version 0.8-2 -
>> I think it is the latest one, see
>> http://cran.r-project.org/web/packages/xts/index.html
>> Maybe someone can confirm correct operation in 0.8-2.  Could this be a
>> Revo/base R version issue?
>>
>> > sessionInfo()
>> R version 2.12.2 (2011-02-25)
>> Platform: i386-pc-mingw32/i386 (32-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> States.1252    LC_MONETARY=English_United States.1252
>> [4] LC_NUMERIC=C                           LC_TIME=English_United
>> States.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] dplR_1.4.7       xts_0.8-2        zoo_1.7-2        Revobase_4.3.0
>>  RevoMods_4.3.0   RevoScaleR_1.2-0 lattice_0.19-23
>>
>>
>> On Fri, Sep 23, 2011 at 8:15 AM, Wolfgang Wu <wobwu22 at yahoo.de> wrote:
>> >
>> > Hmmm works fine for me.
>> >
>> > xts(1, order.by = strptime("04/05/87 2:00",format="%m/%d/%y %H:%M"))
>> >
>> > [,1]
>> > 1987-04-05 02:00:00    1
>> >
>> > Maybe an old version of xts? I am using xts version 0.8-0. (you can check
>> that with sessionInfo().)
>> >
>> > Regards,
>> >
>> > Wolfgang Wu
>> >
>> >
>> >
>> >
>> > ----- Ursprüngliche Message -----
>> > Von: Dan Potter <arsanalytica at gmail.com>
>> > An: r-sig-finance at r-project.org
>> > Cc:
>> > Gesendet: 12:51 Freitag, 23.September 2011
>> > Betreff: [R-SIG-Finance] xts NA date for
>> >
>> > Hello All,
>> > I am new to R and having an issue with xts when I try and used it with
>> > certain dates and times in 1987.
>> >
>> > Example
>> >
>> > > # This date and time works
>> > > xts(1, order.by = strptime("04/05/87 12:00",format="%m/%d/%y %H:%M"))
>> > [,1]
>> > 1987-04-05 12:00:00 1
>> >
>> > # This date and time do not work
>> > > xts(1, order.by = strptime("04/05/87 2:00",format="%m/%d/%y %H:%M"))
>> > [,1]
>> > <NA> 1
>> >
>> > I don't think the issue is with strptime since it seems to work fine
>> > on the offending date and time, i.e.
>> > > strptime("04/05/87 02:00",format="%m/%d/%y %H:%M")
>> > [1] "1987-04-05 02:00:00"
>> >
>> > Any suggestion or work arounds would be appreciated.
>> >
>> > Thanks,
>> > Dan
>> >
>> > _______________________________________________
>> > R-SIG-Finance at 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.
>> >
>>
>> _______________________________________________
>> R-SIG-Finance at 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]]
>
>
> _______________________________________________
> R-SIG-Finance at 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com



More information about the R-SIG-Finance mailing list