Read this https://stackoverflow.com/questions/8175912/load-multiple-packages-at-once邮政。
和this https://stackoverflow.com/questions/8681688/disable-messages-upon-loading-a-package one.
我想在 oner 中加载包并抑制suppressPackageStartupMessages
同时。
第一个链接中的答案使用 lapply:
packages <- c("tidyverse", "qdap", "stringr", "stringi", "textstem", "foreach", "caret", "xgboost", "quanteda")
lapply(packages, require, character.only = T)
这将向控制台返回一个难看的列表:
[[1]]
[1] TRUE
[[2]]
[1] TRUE
[[3]]
[1] TRUE
[[4]]
[1] TRUE
另外,我还想删除那些在加载时发送到控制台的消息,例如
> library(tidyverse)
Loading tidyverse: ggplot2
Loading tidyverse: dplyr
Conflicts with tidy packages --------------------------------------------------------------------
accumulate(): purrr, foreach
filter(): dplyr, stats
lag(): dplyr, stats
when(): purrr, foreach
有没有一种聪明、简短的方法来加载包向量并抑制PackageStartupMessages?