https://github.com/randy3k/retry
Repeated Evaluation
https://github.com/randy3k/retry
Last synced: 28 days ago
JSON representation
Repeated Evaluation
- Host: GitHub
- URL: https://github.com/randy3k/retry
- Owner: randy3k
- License: other
- Created: 2020-04-05T04:18:37.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-23T06:08:10.000Z (about 1 year ago)
- Last Synced: 2025-03-14T21:04:08.795Z (about 1 month ago)
- Language: R
- Homepage: https://randy3k.github.io/retry/
- Size: 108 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - randy3k/retry - Repeated Evaluation (R)
README
---
output:
github_document:
html_preview: false
---```{r results='asis', echo = FALSE, eval = TRUE}
d <- read.dcf("DESCRIPTION")
``````{r results="asis", echo = FALSE, eval = TRUE}
title <- d[colnames(d) == "Title"]
cat(c("# ", paste(trimws(strsplit(title, "\n")[[1]]), collapse = " ")))
```[](https://github.com/randy3k/retry/actions/workflows/check.yaml)
[](https://app.codecov.io/gh/randy3k/retry)
[](https://cran.r-project.org/package=retry)
[](https://cran.r-project.org/package=retry)Github: [https://github.com/randy3k/retry](https://github.com/randy3k/retry)
Documentation: [https://randy3k.github.io/retry](https://randy3k.github.io/retry/)
```{r results="asis", echo = FALSE, eval = TRUE}
cat(d[colnames(d) == "Description"])
```## Installation
You can install the released version of retry from [CRAN](https://CRAN.R-project.org) with:
```r
install.packages("retry")
```The development version could be installed with:
```r
devtools::install_github("randy3k/retry")
```## Example
Some examples of `retry` and `wait_until`.
```r
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] 2z <- 0
later::later(function() z <<- 1, 1)
wait_until(z == 1)
z
#> [1] 1
```