问题
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