【发布时间】:2020-02-03 19:28:09
【问题描述】:
伙计们!
我需要在我的数据帧中使用函数 Return.calculate(),但是要使用这个函数,首先,我需要将我的数据帧转换为 xts。
这是我的数据框:
head(df)
datas preco ticker empresa
1 20180102 32.09 BBAS3 BRASIL
2 20180103 33.10 BBAS3 BRASIL
3 20180104 33.52 BBAS3 BRASIL
4 20180105 33.70 BBAS3 BRASIL
5 20180108 33.64 BBAS3 BRASIL
6 20180109 33.59 BBAS3 BRASIL
当我尝试使用 as.xts() 或 xts() 将我的数据帧转换为 xts 时,我收到以下消息:
使用 as.xts():
Error in as.POSIXlt.character(x, tz, ...) :
character string is not in a standard unambiguous format
使用 xts()
Error in xts(z) : order.by requires an appropriate time-based object
如何在 xts 对象中转换我的数据框?
非常感谢
【问题讨论】:
标签: r dataframe return transform xts