Defensive R Programming
Dr. Colin Gillespie
Jumping Rivers
CV 1 of 10 complete
CV 2 of 10 complete
CV 3 of 10 complete
We can turn it off with suppressMessages()
noisy = function(a, b) {
message("I'm doing stuff")
a + b
}
noisy(1, 2)
I'm doing stuff
# [1] 3
suppressMessages(noisy(1, 2))
# [1] 3
suppressPackageStartupMessages(library("ggplot2"))
The message()
function is helpful for letting
know what's happening.
It's very handy for long running processes
Defensive R Programming