Description Usage Arguments Examples
This function tries a certain number of time (maxTries) to assign the result of 'call' to an object called 'target' in the parent frame. Useful for calls that may fail sometimes, e.g. downloading.
1 2 | keepTrying(target, call, maxTries = 5, timeout = 5, noTermination = F,
silent = F)
|
target |
(character) The name under which the result of call should be stored |
call |
(character) The call as a character string |
maxTries |
Try this number of times at maximum |
timeout |
The timeout between tries |
noTermination |
If False (default False) the try-error will be saved in the object of name 'target'. Otherwise the function throws an error via stop() which will interrupt a function that keepTrying is running inside of. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | > keepTrying("theAnswer", "2 + 40")
> theAnswer
42
> keepTrying("thisFails", "2 * 'abc'", maxTries = 2, noTermination = T)
Error in 2 * "abc" : non-numeric argument to binary operator
Trying again in 5 sec.
Error in 2 * "abc" : non-numeric argument to binary operator
> thisFails
[1] "Error in 2 * \"abc\" : non-numeric argument to binary operator\n"
attr(,"class")
[1] "try-error"
attr(,"condition")
<simpleError in 2 * "abc": non-numeric argument to binary operator>
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.