How can I change XTS to data.frame and keep Index?

后端 未结 6 2002
时光说笑
时光说笑 2020-12-02 11:11

I have an XTS timeseries in R of the following format and am trying to do some processing, subsetting and re-arranging before exporting as a CSV for work in another program.

6条回答
  •  渐次进展
    2020-12-02 12:13

    Since 1.9.6 You can convert directly from/to xts without losing index class. As simple as:

    as.data.table(master_1)
    

    The index is added as the first column in the result data.table, it retains index Date or POSIXct classes.

提交回复
热议问题