Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

retry

Retry calling a function for a number of times


Description

If the function returns an error, retry it for the specified number of times, with a pause between attempts.

Usage

retry(fun, ..., .times = 3, .pause = 5)

Arguments

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.

Details

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.

Examples

# read the Github releases info of the repo yihui/xfun
if (interactive()) xfun::retry(xfun::github_releases, "yihui/xfun")

xfun

Miscellaneous Functions to Support Packages Maintained by 'Yihui Xie'

v0.22
MIT + file LICENSE
Authors
Yihui Xie [aut, cre, cph] (<https://orcid.org/0000-0003-0645-5666>), Wush Wu [ctb], Daijiang Li [ctb], Xianying Tan [ctb], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Christophe Dervieux [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.