n_times_try: Call TryCatch n times with given sleep times.

View source: R/n_times_try.R

n_times_tryR Documentation

Call TryCatch n times with given sleep times.

Description

Mainly suggested for web scraping when reaching a given domain in a short time leads to errors.

Usage

n_times_try(
  .exp,
  sleep_times = c(3, 3, 3),
  otherwise = NULL,
  print_message = FALSE
)

Arguments

.exp

Expression

otherwise

Value to return if all the tries resulted an error.

print_message

Should print the message (default FALSE).

sleep_time

Numeric vector given the seconds to wait for next try.

Examples

v <- list("a", "B", 2) # only 3rd element can be added to another numeric
i = 0
n_times_try({
i = i + 1
v[[i]] + 3
})


MarcellGranat/granatlib documentation built on July 9, 2023, 6:08 a.m.