我有一个 csv 文件,其中包含字段 "Date","Time","O","H","L","C","V" 我想将它与 quantmod 包中的 getSymbols 函数一起使用。csv 文件 (h1.csv) 如下所示:
"Date","Time","O","H","L","C","V"
20070801,0001,1.3668,1.3675,1.3666,1.3673,20693
20070801,0100,1.3671,1.3674,1.3652,1.3653,26636
20070801,0200,1.3655,1.3669,1.3651,1.3667,31300
代码:
library(quantmod)
setSymbolLookup(h1=list(src='csv', format='%Y%m%d'))
h1 <- getSymbols('h1', dir='C:\\Users\\Admin\\Documents\\R\\csv', auto.assign=FALSE, extension='csv')
barChart(h1)
R发送错误:周期性(x):无法计算1次观察的周期性
但是当我使用这个 R 代码时:
library(quantmod)
getSymbols("SPY")
write.zoo(SPY, file="SPY.csv", sep=",")
setSymbolLookup(SPY=list(src="csv",format="%Y-%m-%d"))
spy <- getSymbols("SPY", auto.assign=FALSE)
barChart(spy)
一切都好