[R] How to stop function printing unwanted output?

Erik Iverson eiverson at NMDP.ORG
Thu Aug 6 18:24:41 CEST 2009


>> In my example, I don't want LSD.test to print any output, I just want
>> to use some of it later... How to stop it printing anything?

>?invisible


I'm not sure that works in this situation: 

test <- function() {
  print("output")
}

test()
invisible(test())

Both of the above still print out "output", which I think is the original problem. The invisible function will not print the value of a function, but if there is an explicit "print" call within the function, that will of course happen, since the value hasn't been returned at that point.  However, we don't know the original problem since LSD.test is not defined, and therefore the example is not reproducible.  I assume within the function, it is printing out some values using "print" or "cat"?  We just have to guess though.  

Maybe the answer is in ?sink ??

Erik 




More information about the R-help mailing list