将股票行情数据保存到CSV

以下从我猜雅虎下载了股票代码。

我需要将其保存到.csv并可能将格式调整为以下格式:

Date,Open,High,Low,Close,Volume
2020-05-21,222.9,222.96,222.43,222.9,10809
2020-05-20,222.12,222.44,221.75,222.16,4462
2020-05-19,221.92,222.21,221.49,222.12,10490
2020-05-18,223.08,223.23,222,222.2,4307

有什么建议吗?

ticker_symbol <- c('AAPL') 
sDate <- as.Date("2017-01-01") #Start Date
eDate <- as.Date(Sys.Date()) #End   Date

get.symbol <- function(ticker) {  
tryCatch(temp <- Ad(getSymbols(ticker, auto.assign=FALSE, 
                               from = sDate, to = eDate, warning = FALSE)),    
         error = function(e) {
           message("-ERROR-")
           message(paste("Error for ticker symbol  :", ticker, "\n"))
           message("Here's the original error message: ")
           message(e)
           message("")
           return(NULL)},
         finally = {
           message(paste("Data was processed for symbol:", "[", ticker, "]" ))
           message("\n","******************************************", "\n")  
         }) 
}
prices <- do.call(cbind,lapply(ticker_symbol,get.symbol))
names(prices) <- gsub("\\..+","",names(prices))  # remove ".Adjusted" from names
head(prices)