[R] intraday zoo

Gabor Grothendieck ggrothendieck at gmail.com
Fri Dec 3 15:23:58 CET 2010


On Fri, Dec 3, 2010 at 7:37 AM, Santosh Srinivas
<santosh.srinivas at gmail.com> wrote:
> I'm trying to read intraday zoo but running into issues (again) ...
> what am I missing here? (the date doesn't seem to read in correctly)
>
>> head(dat)
>   TrdDate  TrdTime impliedVol
> 1 20090102 09:55:03  0.3610715
> 2 20090102 09:55:04  0.3637943
> 3 20090102 09:55:05  0.3752375
> 4 20090102 09:55:05  0.4190025
> 5 20090102 09:55:06  0.3696080
> 6 20090102 09:55:06  0.4944981
>
>>  f <- function(x) chron(x[,1],x[,2], format=c(dates="ymd", times="h:m:s"))
>
>> head(z)
> (741031 09:55:03) (741031 09:55:04) (741031 09:55:05) (741031
> 09:55:05) (741031 09:55:06) (741031 09:55:06)
>        0.3610715         0.3637943         0.3752375
> 0.4190025         0.3696080         0.4944981
> Warning message:
> In zoo(rval[i], x.index[i]) :
>  some methods for “zoo” objects do not work if the index entries in
> ‘order.by’ are not unique

Try using as.chron:

> chron(20090102, "09:55:06", format = c("ymd", "h:m:s"))
[1] (741031 09:55:06)
>
> as.chron("20090102 09:55:06", "%Y%m%d %H:%M:%S")
[1] (01/02/09 09:55:06)



You need to show the actual statement you used but I suspect that the problem


-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list