0

I have recently plunged into R on a totally self-taught basis (may not have been the smartest decision!)

I am attempting to download tickers as a time series. I can successfully create RDA files but I want to convert them to CVS. Following is the code I have created so far.

if (!require(BatchGetSymbols)) install.packages('BatchGetSymbols')
library(BatchGetSymbols)

tickers <- c('SPY','VCR', 'RPG')
first.date <- Sys.Date() - 365
last.date <- Sys.Date
l.out <- BatchGetSymbols(tickers = tickers, 
                         first.date = first.date,
                         last.date = last.date,
                         cache.folder = file.path("c://Users/Owner/Documents/R",
                                                  'BGS_Cache') )

print(l.out$df.control)
print(l.out$df.tickers)

I can print(l.out) and see that it contains all the data, but it is not a data.frame

Can anyone help with creating a data.frame and then converting to CSV?

divibisan
  • 11,659
  • 11
  • 40
  • 58
  • 1
    Can you copy and paste the output of `dput(head(l.out))` into your question please? Having a sample of the data helps clarify what the problem is. – Mako212 Sep 14 '18 at 18:19
  • `as.data.frame` will convert an object into a data.frame and `write.table` with the appropriate arguments will write an object as a `.csv` file. If you can't figure it out from that, post `dput(l.out)` and `str(l.out)` – divibisan Sep 14 '18 at 18:28
  • 1
    If `l.out` is a list (which maybe it is from the title) then these questions will have your answer: https://stackoverflow.com/questions/4227223/r-list-to-data-frame?rq=1 or https://stackoverflow.com/questions/2851327/convert-a-list-of-data-frames-into-one-data-frame?rq=1 – divibisan Sep 14 '18 at 18:30
  • the as.data.frame and write.table are successful. Thank you for your response? – Jim Blackburn Sep 15 '18 at 20:46

0 Answers0