Open In App

How to disable Messages when Loading a Package in R ?

Last Updated : 17 May, 2021
Like Article

R console displays many messages and warning upon load of some packages and libraries. These messages display the associated packages’ info, the warnings, the masked objects, which may be sometimes redundant and confusing for the user. Therefore, there are methods in R programming language to silence these notifications and ensure a smooth execution. 

Method 1 : Using suppressPackageStartupMessages() method

suppressPackageStartupMessages() method in R language can be used to disable messages displayed upon loading a package in R. This method is used to suppress package startup messages. The package should be pre-installed in R, otherwise, a warning is displayed upon function call. It is a variant of the suppressMessages() method. However, it disables only the messages, and not warnings and errors encountered.

Syntax: suppressPackageStartupMessages(expr)

Parameter : 

  • expr – The expression to be evaluated, which in this case is equivalent to library(THE_PACKAGE_NAME) , in order to ignore the package load warnings.

Return type : TRUE if successful, FALSE otherwise. 

This method should be used after installing the specified package using the install.packages() command. Otherwise, it displays an error in that particular library, due to being unable to locate the package. The below screenshots show the warnings and messages displayed upon a load of package “tibble” in RStudio : 





Multiple libraries’ messages can also be disabled by using suppressPackageStartupMessages({…}) in the console. 

Method 2: Using library method 

The library() method in R is used to load a library into the working space. During the load of library, the quietly attribute can be set in order to eliminate the display of package startup messages. The package masking and attaching messages are displayed without any prior notification in case this parameter is enabled. It is a local parameter, with its scope defined only for the package it is defined with. It doesn’t affect the global settings of package installation. No warning and extra messages are displayed. However, the package should be present in the working space, otherwise, an error is returned. This is in contrast to the suppressPackageStartupMessages method because no message confirming package attaching is printed, and in most of the cases, no errors/warnings are printed even in case of any failure.


library (THE_PACKAGE_NAME, quietly = T)

The below screenshots show the warnings and messages displayed upon load of package “dplyr” in RStudio : 



library (dplyr, quietly = T)


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads