Disable Messages when Loading a Package in R (Example)
In this article you’ll learn how to suppress warning messages when loading an add-on package the first time in R programming.
The tutorial consists of this content:
Let’s start right away!
Example: Loading dplyr Package to RStudio
In this Example, I’ll show how to remove messages when loading a package in R. For this example, I’m using the dplyr package. First, we need to install and load the dplyr package:
install.packages("dplyr") # Install & load dplyr package library("dplyr")
Figure 1 shows the messages that we receive when starting the dplyr package in RStudio.
If we want to disable such messages, we can use the suppressPackageStartupMessages function as shown below:
suppressPackageStartupMessages(library("dplyr")) # Disable messages
No messages appear anymore!
Video, Further Resources & Summary
Do you need more explanations on the R codes of this article? Then you might want to have a look at the following video of my YouTube channel. I’m explaining the content of this post in the video:
The YouTube video will be added soon.
Furthermore, I can recommend to have a look at the related tutorials of https://statisticsglobe.com/. A selection of related tutorials about packages in R can be found below:
- Load Multiple Packages at Once in R
- Find Out Which Package Version is Loaded in R
- Unload Package without Restarting R
- Detach All User-Installed Packages in R
- message, warning & stop Functions in R
- The R Programming Language
At this point of the page you should have learned how to disable package messages at startup in the R programming language. In case you have additional questions, let me know in the comments.
Statistics Globe Newsletter