I am writing an R package with some C ++ code that does lengthy calculations. Inside C ++ code, I use Rprintf () to output information. I tried to suppress the output from R with suppressMessages (), but this does not work, the messages still appear inside the R session.
I found several similar questions when people used printf instead of Rprintf, but I already use Rprintf. I also tried R_ShowMessage (), which is also immediately displayed and not suppressed by suppressMessages ().
Here is a sample C ++ code:
#include <Rh> extern "C" { void R_testprint() { Rprintf("Try to suppress me!\n"); R_ShowMessage("Try to suppress me, too!"); } }
And the function calling this code:
test.print <- function(string) { res <- .C("R_testprint") }
Now the following R code will not suppress the output:
> suppressMessages( test.print() ) Try to suppress me! Try to suppress me, too!
I am using R version 3.1.0
I appreciate any help!
source share