Search code examples
rcsvxtsquantmodwrite.table

passing in a variable to be used with write.table


I am using quantmod to get stock prices for a ticker, which creates an xts object.

When I try to write this object into a csv file, I can't seem to figure out how to call the object using the variable name. See below:

ticker="IBM"
getSymbols(ticker,from='1990-01-01')
write.table(ticker,file="deleteme.csv", col.names=FALSE, sep=',')
write.table(as.data.frame(ticker),file="deleteme2.csv", col.names=FALSE, sep=',')

Does anyone know how I can pass in the variable "ticker" and the write.table command will know that it needs to call the IBM xts data file?

Thank you!!


Solution

  • Found a workaround! We need to turn the auto assign off in the quantmod function.

    symbols<-getSymbols(px_ticker,from='1990-01-01', auto.assign=F)