[R-SIG-Finance] time index in high frequency data

Santosh Srinivas santosh.srinivas at gmail.com
Mon Dec 3 13:31:43 CET 2012


You could find more direction on the r-help list .. I remember using
help from that list

You can do something like this.  (Code pasted from my routine)

f2 <- function(d, t, format = "%Y%m%d %H:%M:%S") {
as.POSIXct(strptime(paste(d, t),format=format))
}

require(zoo)
optData.z <- read.zoo(optData.df.1[c(1:2,5:11)],index=list(1,2), FUN=f2)

The index columns refer to the date and time in your dataset.

zoo objects can be converted to xts using as.xts

I think you should be able to create xts directly using a similar approach


On Mon, Dec 3, 2012 at 5:10 PM, Wei-han Liu <weihanliu2002 at yahoo.com> wrote:
> Hi R users:
>
> I have a high frequency dataset with the following two time indexes: TDATE and TTIME. I would like to read in the following series in the specific data format: yyyy-mm-dd and hh-mm, and convert them as xts objects. Could any people can share some advice in this regard?
>
> Many thanks.
>
> Wei-han
>
> TDATE TTIME
> 20091009 930
> 20091009 1130
> 20091009 1500
> 20091012 930
> 20091012 1130
> 20091012 1500
> 20091013 930
> 20091013 1130
> 20091013 1500
> 20091014 930
> 20091014 1130
> 20091014 1500
> 20091015 930
> 20091015 1130
> 20091015 1500
> 20091016 930
> 20091016 1130
> 20091016 1500
> 20091019 930
> 20091019 1130
> 20091019 1500
> 20091020 930
> 20091020 1130
> 20091020 1500
> 20091021 930
> 20091021 1130
>         [[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.



More information about the R-SIG-Finance mailing list