In R some functions can print information and return values, can the print be silenced?
For example:
print.and.return <- function() {
print(\"foo\
You may use hidden functional nature of R, for instance by defining function
deprintize<-function(f){
return(function(...) {capture.output(w<-f(...));return(w);});
}
that will convert 'printing' functions to 'silent' ones:
noisyf<-function(x){
print("BOO!");
sin(x);
}
noisyf(7)
deprintize(noisyf)(7)
deprintize(noisyf)->silentf;silentf(7)