[R] Weird POSIXct behaviour
peter dalgaard
pdalgd at gmail.com
Sun Mar 25 11:03:28 CEST 2012
I see "NZDT" going in and out of your time values. Could that have something to do with it?
On Mar 25, 2012, at 10:15 , Worik R wrote:
> Friends
>
> I have an xts that I wish to access.
>
> Browse[2]> DATA.ba[[p]]["2012-03-20 00:59:57","bid"]
> bid
> 2012-03-20 00:59:57 1.4993
>
> So far so good.
>
> Now putting the index into a variable:
>
> Browse[2]> Time
> [1] "2012-03-20 00:59:57 NZDT"
> Browse[2]> DATA.ba[[p]][Time, "bid"]
> bid
>
> Where has it gone?
>
>
> Looking closer....
>
>
> Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"])
> [1] "2012-03-20 00:59:57 NZDT"
> Browse[2]>
>
> Browse[2]> Time
> [1] "2012-03-20 00:59:57 NZDT"
> Browse[2]>
>
> Browse[2]> index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]) == Time
> [1] FALSE
> Browse[2]>
>
> Browse[2]> class(Time)
> [1] "POSIXct" "POSIXt"
>
> Browse[2]> class(index(DATA.ba[[p]]["2012-03-20 00:59:57","bid"]))
> [1] "POSIXct" "POSIXt"
>
> So the variable 'Time' should be good to index DATA.ba[[p]]. I am
> hopelessly confused.
>
> cheers
> Worik
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list