Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
How to disable output messages (prints or cats) from functions in R?
6 messages · Miguel Ratón Almansa, Henrik Bengtsson
See capture.output(). /H
On 11/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Hi, I've tried it but I need the object returned by the function and if I use capture.output() I lose it because It returns a string, not the object. I want the returned object without the displaying information showed by the function. Something like suppressWarnings( ) but suppressing the standard output. Miguel Henrik Bengtsson escribi?:
See capture.output(). /H On 11/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Hi everybody,
after several attempts I've got what I wanted using the sink() function.
If someone need it all you have to do is the following:
sink("aux");
object <- yourFunction(...);
sink(NULL);
Now you can use the returned object without having been showed the
output information.
Miguel
Henrik Bengtsson escribi?:
See capture.output(). /H On 11/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
log <- capture.output({
res <- theFunction(...);
})
print(res);
/H
On 12/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi, I've tried it but I need the object returned by the function and if I use capture.output() I lose it because It returns a string, not the object. I want the returned object without the displaying information showed by the function. Something like suppressWarnings( ) but suppressing the standard output. Miguel Henrik Bengtsson escribi?:
See capture.output(). /H On 11/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Thank you. That works fine. ;-) Miguel Henrik Bengtsson escribi?:
log <- capture.output({
res <- theFunction(...);
})
print(res);
/H
On 12/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi,
I've tried it but I need the object returned by the function and if I
use capture.output() I lose it because It returns a string, not the
object. I want the returned object without the displaying information
showed by the function. Something like suppressWarnings( ) but
suppressing the standard output.
Miguel
Henrik Bengtsson escribi?:
See capture.output(). /H
On 11/01/2008, Miguel Rat?n Almansa <cibermike at telefonica.net> wrote:
Hi everybody, I have to use a function that shows an output message like "# nonzero coefficients ..." followed with a lot of numbers depending on the input. This is very annoying because I have to run that function several times and I don't want to show this information. What I want is to disable that display but I don't know how to do it. I've tried it with suppressWarnings ( function (...) ) and suppressMessages ( function (...) ) but It doesn't work, the function() continues printing that information. I tried invisible () too. Furthermore, this function doesn't have a "verbose" parameter. Thus, I can't disable it using a verbose parameter. I'm sure that there must be some procedure in R to do it but after searching through the mailing lists I haven't found anything about it. Thank you for your help, Miguel Rat?n Almansa
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.