Question

I have 2-column (index and value) ZOO object, where index contains date and time values:

2010-02-18 13:11:00 48.090 
2010-02-18 13:12:00 48.110 
2010-02-18 13:13:00 48.100

I want to save this ZOO object into CSV by separating index column into two independent columns - date column, and time column:

2010-02-18,13:11:00,48.090 
2010-02-18,13:12:00,48.110 
2010-02-18,13:13:00,48.100

How I can do this?

Was it helpful?

Solution

y <- data.frame(
    date=format(index(x), '%Y-%m-%d'),
    time=format(index(x), '%H:%M:%S'),
    x=as.numeric(x)
)
write.csv(y, ...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top