Description Usage Arguments Details Value Examples
Handle conditions
1 2 3 4 5 | handle_conditions(expr, condition = "message", times = 1)
handle_messages(expr, times = 1)
handle_warnings(expr, times = 1)
|
expr |
an expression |
condition |
(character) one of "message" or "warning" |
times |
(integer) max. times a condition should be thrown. default: 1 |
Uses ConditionKeeper internally
whatever the expr
returns
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | foo <- function(x) {
message("you gave: ", x)
return(x)
}
foo('a')
capture_message(foo('a'))
handle_conditions(foo('a'))
suppressMessages(handle_conditions(foo('a')))
handle_conditions(foo('a'), "message")
bar <- function(x) {
for (i in x) message("you gave: ", i)
return(x)
}
bar(1:5)
handle_conditions(bar(1:5))
handle_messages(foo('a'))
hello <- function(x) {
warning("you gave: ", x)
return(x)
}
handle_warnings(hello('a'))
# code block
handle_warnings({
as.numeric(letters[1:3])
as.numeric(letters[4:6])
as.numeric(letters[7:9])
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.