In R / RStudio running on Windows, can we make messages (), warning () and error () use different colors in the console?

I use a lot of posts, for example. message("dadida") in one of my projects, and it is annoying to see all this red text everywhere, always making me wonder if there is an error or warning somewhere.

I need these messages in the final product, so I can’t just delete them. But if there is a way to make messages, warnings and errors appear in different colors in the console, this will solve my problem. I did not find a way to do this.

Edit

Thank you all for your input. I did not understand that the red color for all these types of messages is specific to RStudio. In RGui, all this is just white text. If setting up RGui in RGui is not possible, is it probably in RStudio?

+5
source share
1 answer

While I don’t know how to configure output in RGui or RStudio for Windows, using cat () instead of message () will avoid the red text in RStudio. Instead of using

 message("Hello!") 

using

 cat("Hello!\n") 

(pay attention to \ n, which is necessary to get a new line).

There are some subtle differences between message () and cat () that can make a difference when you redirect your output, for example. into a LaTeX document using Sweave, so cat () may not be a suitable replacement in all settings.

+3
source

Source: https://habr.com/ru/post/1206592/


All Articles