Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing some messages in R but leaving others?

Tags:

r

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.

like image 528
Emily Avatar asked Mar 19 '12 18:03

Emily


1 Answers

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.

like image 101
Lars Kotthoff Avatar answered Oct 15 '22 20:10

Lars Kotthoff