I have a collection of complicated R scripts, and decided to have all my debug-related messages called via message()
. I was trying to find a way to suppress all messages, and stumbled upon this SO post, which recommended I try using sink()
. So I inserted the following lines of code into my script, and set my config$debug_mode <- FALSE
:
if (!config$debug_mode){
messages <- file("messages.Rout", open = "wt")
sink(messages, type = "message")
}
The other SO post and R documentation says to simply call sink()
or sink(file=NULL)
to stop the previous diversion, but this is not working for me. Even after calling sink()
, I don't see the R Studio console output from my message()
calls. Also, sink.number()
returns 0
, which seems to suggest that there are no diversions in place. Why, then, am I no longer seeing output in my R Studio console?