On Wed, Mar 2, 2011 at 5:14 PM, rivercode <aqua...@gmail.com> wrote:
> Is there a easy way to create the time index for a zoo/xts object for every
> 100 milliseconds.
>
> eg.  time Index would be:
>
> 10:00:00:100
> 10:00:00:200
> 10:00:00:300
> 10:00:00:400
>
> I am looking to build an empty zoo/xts object with time index from 10am to
> 3pm, index jumps by 100ms each row.
>

Here are three ways.  as.xts(z2) could be used to turn the second one into xts.

library(zoo)
library(chron)
len <- 5 * 60 * 60 * 10 + 1

# use chron times class

z1 <- zoo(, seq(times("10:00:00"), times("15:00:00"), length = len))

# use POSIXct times

z2 <- zoo(, seq(as.POSIXct("2011-01-01 10:00:00"),
        as.POSIXct("2011-01-01 15:00:00"), length = len))

# number intervals from 1 to len

z3 <- zoo(, seq_len(len))



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

______________________________________________
R-help@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.

Reply via email to