2

Possible Duplicate:
Library/package development - message when loading

I want to set up a web interface using Rapache; however, the underlying R code uses packages that display a quick message from the author. E.g., for data.table,

Quick start guide : vignette("datatable-intro") Homepage : http://datatable.r-forge.r-project.org/

Is there a way to avoid this? I tried suppressMessages(), and the quietly option to library(), but to no avail.

Thanks

Community
  • 1
  • 1
crayola
  • 1,668
  • 13
  • 16
  • Exact duplicate of: http://stackoverflow.com/q/2192360/602276 – Andrie Jun 22 '11 at 11:36
  • 2
    Really? It seems that this person wants to print a message. I want to *avoid* printing it. – crayola Jun 22 '11 at 11:43
  • 1
    Did you try `suppressPackageStartupMessages`? – Marek Jun 22 '11 at 11:50
  • I hadn't, because the help on suppressMessages() suggests that it should also suppress package startup messages; however I now tried it, and it didn't work. However, I am now of the opinion that this problem is specific to `data.table` (and maybe other packages, but not all); presumably the startup message is written using cat() or an equivalent function rather than something that suppressMessages() would be able to suppress. I added a `data.table` tag as a consequence. – crayola Jun 22 '11 at 11:53
  • If it's done using `cat`, can you surround it with sink commands to reroute the output to a file (if that works for you)? – Nick Sabbe Jun 22 '11 at 12:10
  • 2
    Better, contact the author of the package and encourage them to use the `packageStartupMessage()` function to write messages that are printed during load/attach. – Gavin Simpson Jun 22 '11 at 12:37
  • Good advice from Gavin. The email address to use is returned by the R command: maintainer("") – Matt Dowle Jun 22 '11 at 12:46
  • 1
    Yes indeed Matt :) we have been bugging a few packages authors to alter their startup code to make it 'suppressable' which is preferred for scripting etc – Dirk Eddelbuettel Jun 22 '11 at 12:48
  • Which I saw, and did (a few days ago) :-) – Matt Dowle Jun 22 '11 at 12:50
  • I agree.. The question is asked from a very different angle, meaning that merging the answers would be very misleading. It is true that there is some overlap; the information there is relevant here, and vice versa; but is that a sufficient reason to close a thread? – crayola Jun 26 '11 at 07:54

2 Answers2

10

For data.table, this was done in commit 233 (2011.06.11 01:04:27) :

"onAttach now uses packageStartupMessage so the banner can be suppressed by those annoyed by banners, whilst still being helpful to new users"

This is in v1.6.1 available from R-Forge, and may be released to CRAN soon.

I'll add a note to NEWS ...

Matt Dowle
  • 58,872
  • 22
  • 166
  • 224
2

The brute force way of suppressing all output and messages for chatty packages is to use sink:

t <- tempfile()
tcon <- file(t,open="w+")
sink(file=tcon,type='output')
sink(file=tcon,type='message')
require(YOURLIBRARY)
sink(NULL,type='output')
sink(NULL,type='message')
unlink(t)

TAKE THAT YOU CHATTY PACKAGE!

Jeff
  • 1,426
  • 8
  • 19