Is there a way to output text to the R console in color

notuo picture notuo · May 29, 2012 · Viewed 22.3k times · Source

I am writing a script and I want to output text messages to the console with different colors depending on conditions. For example: RED for errors and BLUE for warnings, etc.

I am using RStudio.

Answer

krlmlr picture krlmlr · Apr 21, 2015

Check out the new crayon package:

library(crayon)
cat(blue("Hello", "world!\n"))

More info on the GitHub page.

Works in RStudio 1.2.360+