R xts converts numbers to strings - why?

筅森魡賤 提交于 2019-12-10 19:18:22

问题


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)



来源:https://stackoverflow.com/questions/15635590/r-xts-converts-numbers-to-strings-why

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!