R crashes when prophet model run in a loop and the termination of the loop is not in a particular fashion i.e. it crashes R randomly.
for(j in seq_along(unique_code_train)) {
train1 <- filter(train, CODE == unique_code_train[j])
train1 <-arrange(train1, BILLDATE)
train1 <-data.table(train1)
names(train1) <- c("ds", "y") # billdate = ds , sum(saleamt) = y
m <- prophet(train1, changepoint.range = 1.0, seasonality.mode =
'multiplicative', holidays = holidays)
future <- make_future_dataframe(m, periods = 26)
forecast <- predict(m, future)
forecast$yhat <- as.integer(forecast$yhat)
}