1. The message() function
When running R code, we often want to give users a clue on the progress of the routine.
2. The message() function
The message function is used to provide information to a user about a task.
It's not suggesting there's an error - it's just being helpful.
For example, suppose you are fitting an incredibly sophisticated machine learning model,
sorry, I meant to say AI model. Then having a simple output giving the user an idea of
how the fitting is proceeding is essential.
3. Stop talking to me
When developing code, having message() provide feedback is useful. But eventually
we want to mute the noise produced by the function.
Easy, just use the suppressMessages() function. The argument is simply the function
we want to be quiet.
4. Telling packages to be quiet
We can also use the same trick with packages. For example, the ggplot2 package
occasionally prints a start-up message. Since the package author considerately used the
message function, we can simply switch the message off using the concisely named
suppressPackageStartupMessages() function.
5. Using message()
Overall the message function is a really handy, and an easy to use tool for letting
you and your users know what is happening in a function.
I use messages whenever I have a long running process.
6. Let's do some work!
Right, let's do some work!