This function prints a formatted message explaining the reasoning for a section of code and then prints the result of evaluating the provided expression. This function is intended to be run interactively in the R console to aid in code understanding and debugging.

explain(.msg, .expr)

Arguments

.msg

A character string containing the explanatory message for the code.

.expr

An expression representing the R code to be executed.

Value

Invisible NULL. This function is used for its side effect of printing to the console.

Examples

if (FALSE) {
dat <- Theoph
dat$Time[2] <- 0
explain("Subject 1 has duplicate time 0", {
  dat %>% filter(Subject == 1, Time == 0)
})
}