I have an xts object, the first column of which is date-time, followed by OHLC. when I type
>test
it prints the correct output as follows:
2010-09-08 15:13:00 115 115 110 115
2010-09-08 15:14:00 120 125 115 125
however, when I try write.csv(test,”test.csv”)
it only writes the OHLC – why. what command do I use to also write the date-time
this is what str(test) looks like:
An ‘xts’ object from 2010-06-30 15:47:00 to 2010-09-08 15:14:00 containing:
Data: num [1:21757, 1:4] 215 220 205 195 185 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:4] "y.Open" "y.High" "y.Low" "y.Close"
Indexed by objects of class: [POSIXlt,POSIXt] TZ:
xts Attributes:
NULL
Yes you can, and the easiest way may be via
write.zoo:and here is a complete example:
So now that we have our data, it is just a matter of writing it:
Edit on 25 Jan 2012 Use
row.names=FALSE, notTRUEto suppress double row names. And asrow.names=FALSEis the default, remove it from the call.