Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress package loading message in R package NAMESPACE

Tags:

namespaces

r

I am importing a package called "KernSmooth" and want the start up message not to show up ...

In my Description file:

Package: test
Title: Test
Author: Mike
Description: Test
Maintainer: Mike
Depends: R(>= 2.10.0)
Imports: KernSmooth

And my Namespace file:

import(KernSmooth)

But when I load the package I still get the start up message:

KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009

Is my only option not to import it in NAMESPACE and use

suppressMessages(require(KernSmooth)) 

within my R function to avoid the message?

like image 451
Andy Avatar asked Apr 17 '14 20:04

Andy


1 Answers

You can create a .Rprofile file in the main directory of your R project, in which you tell to suppress messages in response of certain commands. Here it follows an example of .Rprofile that suppresses the startup messages for package(KernSmooth):

#This is the command you must put in your .Rprofile:
#obviously you can choose other packages instead of
#KernSmooth, as well as include other personal settings

suppressPackageStartupMessages(library(KernSmooth))

Now, every time you start your R session, you will not see the startup messages when you load package KernSmooth.

You can find more info on .Rprofile typing '?Startup' on your R console, or you can look at this discussion for .Rprofile examples: Expert R users, what's in your .Rprofile?

like image 134
Eugen Avatar answered Oct 31 '22 09:10

Eugen