log_eval | R Documentation |
Evaluate an expression and log results
log_eval(expr, level = TRACE, multiline = FALSE)
expr |
R expression to be evaluated while logging the expression itself along with the result |
level |
|
multiline |
setting to |
log_eval(pi * 2, level = INFO)
## lowering the log level threshold so that we don't have to set a higher level in log_eval
log_threshold(TRACE)
log_eval(x <- 4)
log_eval(sqrt(x))
## log_eval can be called in-line as well as returning the return value of the expression
x <- log_eval(mean(runif(1e3)))
x
## https://twitter.com/krlmlr/status/1067864829547999232
f <- sqrt
g <- mean
x <- 1:31
log_eval(f(g(x)), level = INFO)
log_eval(y <- f(g(x)), level = INFO)
## returning a function
log_eval(f <- sqrt)
log_eval(f)
## evaluating something returning a wall of "text"
log_eval(f <- log_eval)
log_eval(f <- log_eval, multiline = TRUE)
## doing something computationally intensive
log_eval(system.time(for (i in 1:100) mad(runif(1000))), multiline = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.