How can you always suppress messages in R?
r
Solution
Use the type parameter in sink
# Open a file to send messages to
zz <- file("messages.Rout", open = "wt")
# Divert messages to that file
sink(zz, type = "message")
message("not gonna show up in console")
Problem
The most common place I've seen messages used in R is in the starting of a package. Suppressing one function's worth of messages is easily accomplished with `suppressMessages` as discussed here: Disable Messages Upon Loading Package in R. It is also possible to suppress multiple lines of message generating function calls by embedding `{}` inside of the `supressMesssages` function call. However, if you have a full script with messages happening here and there, is there anyway to disable them completely? I'm looking for something like option(warn=-1) but for messages. Please note that `sink` doesn't quite do what I want because it redirects all output... I would like to keep output from `print` but not hold onto output from `message`.