Re: [R] Create a zoo/xts Time Series with Millisecond jumps

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed, 02 Mar 2011 18:20:42 -0500

On Wed, Mar 2, 2011 at 5:14 PM, rivercode <aquanyc_at_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_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.
Received on Wed 02 Mar 2011 - 23:26:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Mar 2011 - 02:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive