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)

Arguments

expr

An expression containing the ic() function.

Value

Returns the result of evaluating the expression.

Functions

  • with_ic_enable(): evaluates the expression with ic() enabled.

  • with_ic_disable(): evaluates the expression with ic() disabled.

Examples

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