chatty: Used to define whether a function is chatty or not

Description Usage Arguments Examples

View source: R/chatty.R

Description

Can be used to make a function talk more or not depending on the verbose argument. This will return either a cat() function (with arguments separated by "\n" to make it easier to read), or a silent function depending on verbose. Should only really be used within another function to decide whether to output to notes/feedback to the console or not throughout it's run. It does no evaluating of arguments and so everything should be easily (i.e. by cat()) coercible to a character.

Usage

1
chatty(verbose)

Arguments

verbose

logical. Should chatty return a chatty function or not.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
I_talk <- chatty(TRUE)
I_talk("hello")
I_talk("I talk", "more...")

Im_silent <- chatty(FALSE)
Im_silent("I don't say", "anything")

f <- function(x, verbose = FALSE) {
  I_talk <- chatty(verbose)
  I_talk("hello world", "I am inside the f() function")
  I_talk("I'm calculating the mean...")
  mean(x)
}

f(1:10)

f(1:10, verbose = TRUE)

MyKo101/mutils documentation built on July 28, 2020, 8:52 p.m.