R xts converts numbers to strings - why?

2019-07-07 02:19发布

问题:

When I convert to a xts object, R changes the values from numbers to strings, which causes problems:

timeseries <- xts(timeseries,as.POSIXct(timeseries$Date))
timeseries <- timeseries[endpoints(timeseries,ts_ret_freq)]

This is the code in question. Why is this the case? It shouldnt be.

Thanks in advance.

回答1:

Because an xts object is essentially a matrix object. Hence all the columns of the xts will always be of same datatype (class)



标签: r format xts