Display a progress bar displaying the estimated time. The purpose of having various estimation methods is to provide a more accurate estimation when the run time between ticks is assumed to be different, e.g., online estimation, time series cross validation, expanding window approach, etc.
lazyProgressBar(n, method = "average", fn = NULL, ...)
n  Integer. Total number of ticks 

method  Character. The embedded forecasting method of remaining time:

fn  Function. User defined function to estimate the remaining time.
The function should predict the remaining time using the arguments and
return a scalar.
It should have at least three arguments in the order of

...  Other arguments to pass to estimation method. The arguments need to be named. 
An R6 object with methods tick()
and print()
.
Four simple forecasting methods are available for
the estimation of the remaining time:
Average method (default), Drift method, Naive method and
Seasonal naive method.
For the summary of the simple methods, see Chapter 3 of References
.
User can also supply their customised estimation method as a function.
See Arguments
and Examples
.
Hyndman, R.J., & Athanasopoulos, G. (2018) Forecasting: principles and practice, 2nd edition, OTexts: Melbourne, Australia. OTexts.com/fpp2. Accessed on 24/04/2020.
# \donttest{ pb < lazyProgressBar(4) pb$tick() pb$tick() pb$tick() pb$tick() # With linearly increasing run time pb < lazyProgressBar(4, method = "drift") for(i in 1:4){ Sys.sleep(i * 0.2) pb$tick()$print() } # With user defined forecast function # The forecast function itself will # require certain computational power forecast_fn < function(dtime, i, n, s = 10){ # When the number of ticks is smaller than s # Estimate the future run time # as the average of the past if(i<s){ eta < mean(dtime)*(ni) } # When the number of ticks is larger than s # Fit an arima model every s ticks # using forecast package if(i>=s){ if(i %% s ==0){ model < forecast::auto.arima(dtime) } runtime < forecast::forecast(model, h=ni)$mean if(i %% s !=0){ runtime < runtime[seq_len(i %% s)] } eta < sum(runtime) } return(eta) } pb < lazyProgressBar(10, fn = forecast_fn, s=3) for(i in 1:10){ Sys.sleep(i * 0.2) pb$tick()$print() } # }