#' Silences a chunk of code
#'
#' Used as a wrapper to a function, loop, or chunk of code it suppresses any printing
#'
#' @export
#'
#' @param code Chuck of code to be silenced
#' @examples
#' print("hello")
#' silence(print("hello"))
#'
silence <- function(code){
if(.Platform$OS.type == "windows"){
# if working with a Windows machine
sink("NUL")
} else if (.Platform$OS.type == "unix"){
# if working on Unix OS
sink("/dev/null")
} else {warning("Unknown OS")}
# running code
tmp = code
# restoring sink
sink()
# returning function output
return(tmp)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.