View source: R/toggle_message.R
toggle_message | R Documentation |
Quick expansion to the message()
function aimed for use in functions for
an easy addition of a global verbose TRUE / FALSE argument to toggle the
messages on or off
toggle_message(..., verbose)
... |
any message you would normally pass into |
verbose |
logical, usually a variable passed from the function you are using this within |
No return value, called for side effects
# Usually used in a function
my_function <- function(count_fingers, verbose) {
toggle_message("I have ", count_fingers, " fingers", verbose = verbose)
fingers_thumbs <- count_fingers + 2
toggle_message("I have ", fingers_thumbs, " digits", verbose = verbose)
}
my_function(5, verbose = FALSE)
my_function(5, verbose = TRUE)
# Can be used in isolation
toggle_message("I want the world to read this!", verbose = TRUE)
toggle_message("I ain't gonna show this message!", verbose = FALSE)
count_fingers <- 5
toggle_message("I have ", count_fingers, " fingers", verbose = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.