Intermittent error with dates use BatchGetSymbols

I have been using the following script in RStudio and as a PowerBI script successfully but I will intermittently get an error when BatchGetSymbols runs.

Following is the script

if (!require(BatchGetSymbols)) install.packages('BatchGetSymbols')
if (!require(rio)) install.packages('rio')
library(BatchGetSymbols) = Sys.Date() - 1460 = Sys.Date()
tickers <- c('SPY', '^GSPC')
l.out <- BatchGetSymbols(tickers = tickers, 
                         cache.folder = "C://users/owner/documents/r/BGS_Cache")

if (!require(ggplot2)) install.packages("ggplot2")
p <- ggplot(l.out$df.tickers, aes(x =, y = price.close))
p <- p + geom_line()
p <- p + facet_wrap(~ticker, scales = 'free_y')

The error returns the following

Running BatchGetSymbols for:
   tickers = SPY, ^GSPC
   Downloading data for benchmark ticker | Found cache file | Need new data Error in charToDate(x) : 
  character string is not in a standard unambiguous format

Is there any way to trap this error from preventing the script to execute?

Thanks and Regards

Jim B

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.