Retry calling a function for a number of times
If the function returns an error, retry it for the specified number of times, with a pause between attempts.
retry(fun, ..., .times = 3, .pause = 5)
fun |
A function. |
... |
Arguments to be passed to the function. |
.times |
The number of times. |
.pause |
The number of seconds to wait before the next attempt. |
One application of this function is to download a web resource. Since the download might fail sometimes, you may want to retry it for a few more times.
# read the Github releases info of the repo yihui/xfun if (interactive()) xfun::retry(xfun::github_releases, "yihui/xfun")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.