catAndRun: Print Debug Messages Before and After Running Code

View source: R/io.R

catAndRunR Documentation

Print Debug Messages Before and After Running Code

Description

Print Debug Messages Before and After Running Code

Usage

catAndRun(
  messageText = "Running code",
  expr,
  newLine = 2L,
  dbg = TRUE,
  log_time = TRUE
)

Arguments

messageText

text to be printed before running the code

expr

expressions to be run. Enclose more than one expression in curly braces

newLine

integer controlling new lines. 0: no extra new line, 1: new line after messageText, 2: new line after "ok.", 3: new line after both, messageText and "ok."

dbg

logical. If FALSE, output is suppressed.

log_time

logical. If TRUE, the time elapsed during the evaluation of expr is printed.

Value

This function returns the evaluation of expr. The result is returned invisibly so that the result of an assignment as the last expression in exprt does not show up on the console.

Examples

for (newLine in 0:3) {

  catAndRun("work hard", newLine = newLine, {
    cat("hard\nworking\n")
  })

  cat("here.\n\n")
}


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.