15

I'm an R newbie using RScaLAPACK and every time I spawn a new process grid I get a message.

> sla.gridInit(2)
[1] "RScaLAPACK:Process Grid Initialized "

I'm going to put this line in a function and I don't want my function to be spitting out this message. However- I don't want to just sink("/dev/null") the call because for all I know, something somewhere could go wrong and then I'd be suppressing useful output. Basically, I want it to be silent when it succeeds and loud if it fails. What is the best way to accomplish this?

Any thoughts, including design considerations, are welcome.

edit: sla.gridInit() isn't returning anything. The code for sla.gridInit just calls print().

edit: I suppose capturing output is best like in suppress messages displayed by "print" instead of "message" or "warning" in R . At least I will have the output if I want to do something with it.

Community
  • 1
  • 1
Emily
  • 564
  • 1
  • 5
  • 13

1 Answers1

37

You can wrap this function in one of the suppress* functions, suppressMessages, suppressWarnings or suppressPackageStartupMessages. See the help pages of those functions for more details.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
  • 4
    Thanks. I googled for suppressMessages and found another question like this. Turns out suppressMessages can't deal with output from print(). :P http://stackoverflow.com/questions/8797314/suppress-messages-displayed-by-print-instead-of-message-or-warning-in-r – Emily Mar 19 '12 at 19:23