I would like to suppress output in R when I run my R script from the command prompt.
I tried numerous options including --slave
and --vanilla
. Those options lessens the amount of text outputted.
I also tried to pipe the output to NUL
but that didn't help.
By using invisible() function we can suppress the output.
If you are looking to suppress or hide all the output of a bash shell script from Linux command line as well as from the crontab then you can simply redirect all the output to a file known as /dev/null . This file is known as Black Hole which will engulf everything you give without complaining.
The quiet option ( -q ), causes grep to run silently and not generate any output. Instead, it runs the command and returns an exit status based on success or failure. The return status is 0 for success and nonzero for failure.
You can send output to /dev/null, by using command >/dev/null syntax.
Look at help(sink)
to do that. On Unix I'd do
sink("/dev/null") # now suppresses
.... # do stuff
sink() # to undo prior suppression, back to normal now
and the Windows equivalent (with a tip-of-the-hat to Johannes) is
sink("NUL")
....
sink()
Since R (>= 3.6.0), there exists a platform-independent alternative to Dirk Eddelbuettel's answer. Simply type
sink(nullfile()) # suppress output
.... # your code
sink() # end suppressing output
to suppress output on both Linux and Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With