Converting a data frame to xts

后端 未结 9 936
暗喜
暗喜 2020-11-28 04:10

I\'m trying to convert a data frame to xts object using the as.xts()-method. Here is my input dataframe q:

q
                      t x  
1  2006-01-01 00:00:         


        
9条回答
  •  青春惊慌失措
    2020-11-28 04:48

    This is clearly documented --- xts and zoo objects are formed by supplying two arguments, a vector or matrix carrying data and Date, POSIXct, chron, ... type supplying the time information (or in the case of zoo the ordering).

    So do something like

     qxts <- xts(q[,-1], order.by=q[,1])
    

    and you should be set.

提交回复
热议问题