1
2# Use read.zoo to read data with a chron time index
3# Ignore fractional seconds.
4
5library(zoo)
6library(chron)
7library(gsubfn)
8
9# test data
10Lines <- "2006-01-24 02:41:24.00011,1.22930000,5,1.22950000,7
112006-01-25 04:41:24.00011,1.22930000,5,1.22950000,7
122006-01-26 07:41:24.00011,1.22930000,5,1.22950000,7"
13
14# convert to chron
15to.chron <- function(x)
16   strapply(format(x), "([0-9-]+) ([0-9:]+)",
17	~ chron(as.numeric(as.Date(dd)), tt), simplify = c)
18
19read.zoo(text = Lines, sep = ",", FUN = to.chron)
20
21