r - R中的data.frame对象到xts对象的转换

标签 r dataframe xts

我想尽可能有效地将我的 csv 文件转换为 xts 对象。我似乎被困在必须首先应用 read.zoo 方法来创建动物园对象,然后才能将其转换为 xts 对象。

gold <- read.zoo("GOLD.CSV", sep=",", format="%m/%d/%Y", header=TRUE)

Gold <- as.xts (gold, order.by=index(gold), frequency=NULL)

这是将我的初始 GOLD.CSV 文件转换为 R xts 对象的最有效方法吗?

最佳答案

如果它是一个文件,你需要阅读它。

所以使用 read.zoo()像你一样 - 但然后立即转换:

 gold <- as.xts(read.zoo("GOLD.CSV", sep=",", format="%m/%d/%Y", header=TRUE))

好?

关于r - R中的data.frame对象到xts对象的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3508333/

相关文章:

c++ - 局部回归和局部似然法的实现

r - 尝试部署 Shiny 的应用程序 : multiple existing deployments from this application directory already exist 时出错

RMongo 在 Ubuntu 中安装失败并出现段错误

python - 为每一行向 DF 添加唯一组,包括来自其他列的总和

r - 重叠和子集化列

R xts : transform all 0 values in a time series with the last found value different than 0

r - 将 XTS 对象转换为 data.frame

r - 假人的Makefile? Mac OS X

python - 用python数据框中的新结尾替换单词结尾

python - 如何在 pandas 数据框中插入列表