These functions let you evaluate an expression with either ic()
enabled or disabled without
affecting if ic()
is enabled globally.
with_ic_enable(expr)
with_ic_disable(expr)
An expression containing the ic()
function.
Returns the result of evaluating the expression.
ic_enable()
fun <- function(x) {
ic(x * 100)
}
fun(2)
#> ℹ ic| `x * 100`: num 200
with_ic_disable(fun(2))
#> [1] 200
fun(4)
#> ℹ ic| `x * 100`: num 400
ic_disable()
fun(1)
#> [1] 100
with_ic_enable(fun(1))
#> ℹ ic| `x * 100`: num 100