| ConditionKeeper | R Documentation |
R6 class with methods for handling conditions
bucketlist holding conditions
timesnumber of times
condition(character) type of condition, message or warning
new()Create a new ConditionKeeper object
ConditionKeeper$new(times = 1, condition = "message")
times(integer) number of times to throw condition. required. default: 1
condition(character) which condition, one of "message" (default) or "warning"
A new ConditionKeeper object
print()print method for the ConditionKeeper class
ConditionKeeper$print(x, ...)
xself
...ignored
add()add a condition to internal storage
ConditionKeeper$add(x)
xa condition
self
remove()remove the first condition from internal storage; returns that condition so you know what you removed
ConditionKeeper$remove()
the condition removed
purge()removes all conditions
ConditionKeeper$purge()
NULL
thrown_already()has the condition been thrown already?
ConditionKeeper$thrown_already(x)
xa condition
logical
not_thrown_yet()has the condition NOT been thrown yet?
ConditionKeeper$not_thrown_yet(x)
xa condition
logical
thrown_times()number of times the condition has been thrown
ConditionKeeper$thrown_times(x)
xa condition
numeric
thrown_enough()has the condition been thrown enough? "enough" being:
thrown number of times equal to what you specified in the times
parameter
ConditionKeeper$thrown_enough(x)
xa condition
logical
get_id()get the internal ID for the ConditionKeeper object
ConditionKeeper$get_id()
a UUID (character)
handle_conditions()pass a code block or function and handle conditions within it
ConditionKeeper$handle_conditions(expr)
expran expression
the result of calling the expression
clone()The objects of this class are cloneable with this method.
ConditionKeeper$clone(deep = FALSE)
deepWhether to make a deep clone.
handle_conditions()
x <- ConditionKeeper$new(times = 4)
x
x$get_id()
x$add("one")
x$add("two")
x
x$thrown_already("one")
x$thrown_already("bears")
x$not_thrown_yet("bears")
x$add("two")
x$add("two")
x$add("two")
x$thrown_times("two")
x$thrown_enough("two")
x$thrown_enough("one")
foo <- function(x) {
message("you gave: ", x)
return(x)
}
foo('a')
x$handle_conditions(foo('a'))
x <- ConditionKeeper$new(times = 4, condition = "warning")
x
x$add("one")
x$add("two")
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.