Disable messages upon loading a package

后端 未结 5 1964
名媛妹妹
名媛妹妹 2020-11-27 15:49

I have a package in R (ROCR) that I need to load in my R environment. Upon loading the package, a set of messages are printed. This is ordinarily fine, but since the outpu

5条回答
  •  猫巷女王i
    2020-11-27 16:11

    By adding quietly = T as shown below will solve the issue:

    suppressWarnings(suppressMessages(library("dplyr", quietly = T)))
    

    In case of multiple package you can use :

    ## specify the package names
    PKGs <- c("affy","gcrma","readxl","ggplot2","lattice" )
    

    and them use lapply as below:

    lapply(PKGs, library, character.only = TRUE ,quietly = T)
    

提交回复
热议问题