write.zoo的文件路径

时间:2016-04-25 02:59:59

标签: r

我在Mac OSX上使用r并按照本指南下载并维护一系列具有股票价格的CSV。

http://www.thertrader.com/2015/12/13/maintaining-a-database-of-price-files-in-r/

library(quantmod)

startDate = "2000-01-01"
thePath = ""

source(paste("listOfInstruments.R",sep=""))

for (ii in theInstruments){
 print(ii)
 data = getSymbols(Symbols = ii, 
                   src = "yahoo", 
                   from = startDate, 
                   auto.assign = FALSE)
 colnames(data) = c("open","high","low","close","volume","adj.")
 write.zoo(data,paste(thePath,ii,".csv",sep=""),sep=",",row.names=FALSE)
}

我试图将我的R文件与我的CSV文件分开,因此我更改了变量" thePath"到名为csv的现有子目录。例如thePath = "\\csv\\"

然而,这会创建一个实际上名为\csv\^GSPC.csv的文件,而不是写入子文件夹。

指定write.zoo路径的正确方法是什么?

0 个答案:

没有答案