8

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?

Andy
  • 282
  • 4
  • 8
  • 3
    Have you looked into `suppressPackageStartupMessages` ? – Josh O'Brien Apr 17 '14 at 21:31
  • I don't think you can use that in the NAMESPACE? suppressMessages does suppress the messages but I have to load the library in my function. I wanted to see if there was a way to do it through the NAMESPACE. – Andy Apr 17 '14 at 22:58
  • 1
    Perhaps use `library` instead of `require`. I get a message with `require`, and none with `library` – Rich Scriven Apr 18 '14 at 02:11
  • Apparently the KernSmooth author wants to display this message, even when the package is loaded but not attached; you should respect the author's intention, or find another implementation that does not display a message. – Martin Morgan Apr 18 '14 at 13:53
  • 5
    I agree that the author's intention should be respected but I would much rather note use of the package in the vignette than have to see an awkward copyright every time the package is loaded. I still think there should be a way to suppress the message in the NAMESPACE so I will leave the question up. – Andy Apr 18 '14 at 17:34
  • 2
    Have you tried keeping the import and putting the suppressMessages(loadNamespace('KernSmooth')) in your package .onLoad() function ? – Karl Forner Apr 24 '14 at 09:08

1 Answers1

1

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?

Eugen
  • 442
  • 1
  • 9
  • 16