lazybar

Travis build status CRAN_Status_Badge Monthly_Downloads Licence

The R package lazybar provides progress bar showing estimated remaining time. Multiple forecast methods and user defined forecast method for the remaining time are supported.

Installation

You can install the development version from Github with:

# install.packages("devtools")
devtools::install_github("FinYang/lazybar")

Usage

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)*(n-i)
  }
  
  # 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=n-i)$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()
}

License

This package is free and open source software, licensed under GPL-3.