Suppress some messages in R, but leave others?

I am new to R using RScaLAPACK, and every time I create a new process grid, I get a message.

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

I am going to put this line in a function, and I do not want my function to spit out this message. However, I donโ€™t want to just fork out ("/ dev / null") on the call, because, as far as I know, something might go wrong somewhere, and then I will suppress the useful conclusion. Basically, I want him to be silent when he succeeds and loud if he fails. What is the best way to do this?

Any thoughts, including design considerations, are welcome.

edit: sla.gridInit () returns nothing. The code for sla.gridInit just calls print ().

edit: I believe that capturing output is best in suppressing messages displayed using "print" instead of "message" or "warning" in R. At least I will have a way out if I want to do something with it.

+4
source share
1 answer

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

+13
source

Source: https://habr.com/ru/post/1402294/


All Articles