R xts将数字转换为字符串 - 为什么? [英] R xts converts numbers to strings - why?
本文介绍了R xts将数字转换为字符串 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我转换为一个xts对象时,R会将数值从数字更改为字符串,这会导致问题:
timeseries< ; - xts(timeseries,as.POSIXct(timeseries $ Date))
timeseries< - timeseries [endpoints(timeseries,ts_ret_freq)]
这是有问题的代码。
为什么是这种情况?它不应该是。
预先感谢。
解决方案
xts
对象本质上是一个矩阵
对象。因此xt的所有列将始终是相同的数据类型(class)
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.
解决方案
Because an xts
object is essentially a matrix
object. Hence all the columns of the xts will always be of same datatype (class)
这篇关于R xts将数字转换为字符串 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文