Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ retry Public

❗ This is a read-only mirror of the CRAN R package repository. retry — Repeated Evaluation. Homepage: https://github.com/randy3k/retry

License

Notifications You must be signed in to change notification settings

cran/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repeated Evaluation

check codecov CRAN_Status_Badge

Github: https://github.com/randy3k/retry

Documentation: https://randy3k.github.io/retry

Provide simple mechanism to repeatedly evaluate an expression until either it succeeds or timeout exceeded. It is useful in situations that random failures could happen.

Installation

You can install the released version of retry from CRAN with:

install.packages("retry")

The development version could be installed with:

devtools::install_github("randy3k/retry")

Example

Some examples of retry and wait_until.

library(retry)

f <- function(x) {
    if (runif(1) < 0.9) {
        stop("random error")
    }
    x + 1
}

# keep retring when there is a random error
retry(f(1), when = "random error")
#> [1] 2
# keep retring until a requirement is satisified.
retry(f(1), until = function(val, cnd) val == 2)
#> [1] 2
# or using one sided formula
retry(f(1), until = ~ . == 2)
#> [1] 2

z <- 0
later::later(function() z <<- 1, 1)
wait_until(z == 1)
z
#> [1] 1

About

❗ This is a read-only mirror of the CRAN R package repository. retry — Repeated Evaluation. Homepage: https://github.com/randy3k/retry

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages