나는 시세표 목록을 뒤져보고 재무를 받고 내 바탕 화면의 폴더에있는 CSV 파일로 내 보내려합니다. 그러나, 나는 Quantmod 패키지의 viewFinancials()와 관련된 R의 오류로 인해 문제가 발생했습니다. 코드와 오류는 아래와 같습니다.Quantmod get/viewFinancials in Loop
그래서, 내 질문은 어떻게 내 루프가 제대로 실행되도록 금융 클래스의 개체로 변수를 할당 무엇입니까? 또는 누군가 다른 대안을 가지고 있다면, 나는 그것을 듣게 될 것입니다! viewFinancials에
오류 (co.f, 'BS', 'Q') : 여기서
오류 메시지이다 가 'X'가 타입이어야 '계좌'
tickers <- c('AAPL','ORCL','MSFT')
for(i in 1:length(tickers)){
co <- tickers[1]
#co.f <- paste(co,".f",sep='') #First attempt, was worth a try
co.f <- getFin(co, auto.assign=T) # automatically assigns data to "co.f" object
BS.q<-viewFinancials(co.f,'BS',"Q") # quarterly balance sheet
IS.q<-viewFinancials(co.f,"IS","Q") # quarterly income statement
CF.q<-viewFinancials(co.f,"CF","Q") # quarterly cash flow statement
BS<-viewFinancials(co.f,"BS","A") # annual balance sheet
IS<-viewFinancials(co.f,"IS","A") # annual income statement
CF<-viewFinancials(co.f,"CF","A") # annual cash flow statement
d<-Sys.Date()
combinedA <- rbind(BS,IS,CF)
combinedQ <- rbind(BS.q,IS.q,CF.q)
BSAfile <- paste('/Users/dedwards/Desktop/RFinancials/',d,' ',co,'_BS_A.csv',sep='')
BSQfile <- paste('/Users/dedwards/Desktop/RFinancials/',d,' ',co,'_BS_Q.csv',sep='')
write.csv(combinedA, file = BSAfile, row.names=TRUE)
write.csv(combinedQ, file = BSQfile, row.names=TRUE)
}
'co.f'에 데이터를 할당하려면 'auto.assign = FALSE'을 사용해야합니다. – GSee