conditionz (version 0.1.0)

ConditionKeeper: ConditionKeeper

Description

ConditionKeeper

Arguments

times

(integer) number of times to throw condition. required. default: 1

condition

(character) which condition, one of "message" (default) or "warning"

Details

Methods

  • add(x) - add a condition to internal storage

  • remove() - remove the first condition from internal storage; returns that condition so you know what you removed

  • purge() - removes all conditions

  • thrown_already(x) - (return: logical) has the condition been thrown already?

  • not_thrown_yet(x) - (return: logical) has the condition NOT been thrown yet?

  • thrown_times(x) - (return: numeric) number of times the condition has been thrown

  • thrown_enough(x) - (return: logical) has the condition been thrown enough? "enough" being: thrown number of times equal to what you specified in the times parameter

  • get_id() - get the internal ID for the ConditionKeeper object

  • handle_conditions(expr) - pass a code block or function and handle conditions within it

See Also

handle_conditions()

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab