Title: | Print Debugging Made Sweeter |
---|---|
Description: | Provides user-friendly and configurable print debugging via a single function, ic(). Wrap an expression in ic() to print the expression, its value and (where available) its source location. Debugging output can be toggled globally without modifying code. |
Authors: | Lewin Appleton-Fox [aut, cre], Dominik Rafacz [aut] , Ben Stiles [ctb] |
Maintainer: | Lewin Appleton-Fox <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.2 |
Built: | 2024-11-14 02:42:27 UTC |
Source: | https://github.com/lewinfox/icecream |
ic()
These functions enable or disable the ic()
function. While disabled ic()
will do nothing
except evaluate and return its input.
ic_enable() ic_disable()
ic_enable() ic_disable()
These are just convenience wrappers for options(icecream.enabled = TRUE/FALSE)
used to align
the API with the Python version.
Returns the old value of the option, invisibly.
ic_enable()
: Enable ic()
.
ic_disable()
: Disable ic()
.
User-friendly debug statements
ic(x)
ic(x)
x |
An expression, or nothing |
If x
is an expression, returns the result of evaluating x
. If x
is missing nothing
is returned.
f <- function(x) x < 0 ic(f(1)) ic(f(-1))
f <- function(x) x < 0 ic(f(1)) ic(f(-1))
ic()
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)
with_ic_enable(expr) with_ic_disable(expr)
expr |
An expression containing the |
Returns the result of evaluating the expression.
with_ic_enable()
: evaluates the expression with ic()
enabled.
with_ic_disable()
: evaluates the expression with ic()
disabled.
ic_enable() fun <- function(x) { ic(x * 100) } fun(2) with_ic_disable(fun(2)) fun(4) ic_disable() fun(1) with_ic_enable(fun(1))
ic_enable() fun <- function(x) { ic(x * 100) } fun(2) with_ic_disable(fun(2)) fun(4) ic_disable() fun(1) with_ic_enable(fun(1))