[R-SIG-Finance] timeDate class query

Ian Seow ianseow at gmail.com
Fri Jul 11 04:39:08 CEST 2008


Hi, I have a query on the timeDate class in the fCalendar Package.
I have a large data set of intraday observations (in GMT) containing
407,100 POSIXct objects which I want to convert into timeDate objects
and then view the result in my local time zone ('Asia/Singapore').
The conversion works fine, however, it seems that timeDate does not
have 'Dims' and hence does not allow for length(), head() and tail()
to be performed.
In this case, how do I go about printing say the last 6 elements in
this object? If I convert the timeDate object into another class, the
timezone conversion information is lost and I get my return object in
"GMT" which is not what I want. Appreciate any ideas on this?

Here's the code to illustrate my point:


Original Object in POSIXct
==========================

>   class(index(d))
[1] "POSIXt"  "POSIXct"
>   length(index(d))
[1] 407100

>   tail(index(d))
[1] "2008-06-02 12:30:00 Malay Peninsula Standard Time" "2008-06-02
12:35:00 Malay Peninsula Standard Time"
[3] "2008-06-02 12:40:00 Malay Peninsula Standard Time" "2008-06-02
12:45:00 Malay Peninsula Standard Time"
[5] "2008-06-02 12:50:00 Malay Peninsula Standard Time" "2008-06-02
12:55:00 Malay Peninsula Standard Time"
>

Converted object into timeDate class
====================================

>   myTZ = timeDate(index(d), zone='GMT', FinCenter='Asia/Singapore')
>   length(myTZ) ## fails
Error in length.timeDate(myTZ) :
  no slot of name "Dim" for this object of class "timeDate"
>   tail(myTZ) ## fails
Error in length.timeDate(x) :
  no slot of name "Dim" for this object of class "timeDate"
>


Converted object into character Class, but loses timezone conversion
information. Result returned is back in GMT
================================================================================================================

>   tail(as.character(myTZ))
[1] "2008-06-02 12:30:00" "2008-06-02 12:35:00" "2008-06-02 12:40:00"
"2008-06-02 12:45:00" "2008-06-02 12:50:00" "2008-06-02 12:55:00"


Thanks!

Rgds
Ian Seow



More information about the R-SIG-Finance mailing list