I have put some of the functions that I use regularly into one package with roxygen2 and everything is working smoothly. The only thing that bothers me is that upon loading the package I get a wall of text from all the loaded dependencies printed into the console. I know that I can supress warnings when I use suppressWarnings(suppressMessages(library("PACKAGE")))
but I am wondering if I can also set this option directly in the package (maybe in NAMESPACE)? The idea would be that the warnings from the dependencies are suppressed and I can specify my own text that is displayed when the package is loaded.
I tried the suggestion of @NelsonGon and added this to a file called zzz.R
. The additional welcome text is printed as it should be but the loading messages from the dependcies are still printed.
# Welcome message
.onLoad <- function(...){
invisible(suppressPackageStartupMessages(
sapply(c("stringi", "stringr",
"qdapRegex", "readr",
"tokenizers", "rvest",
"pryr", "XML", "xml2",
"lubridate", "data.table",
"ggplot2", "anytime", "dplyr",
"network", "quanteda", "ggmap",
"networkDynamic", "mgsub",
"dplyr", "ggplot2", "network",
"stats", "ndtv", "devtools",
"ggtext"),
requireNamespace, quietly = TRUE)))
pkg_info <- "Welcome to my package"
packageStartupMessage(pkg_info)
}