Skip to contents

Print Coloured Messages

Usage

formatColoured(
  txt,
  colour = c("yellow", "blue", "grey"),
  bold = FALSE,
  cat = TRUE
)

Arguments

txt

Character. Text to print or transform.

colour

Character. Any of: grey, red, green, yellow, blue, or purple.

bold

Boolean. Set bold text?

cat

Boolean. Print with cat? If not, raw string

Value

Depends on cat: NULL if TRUE or character string if FALSE.

Examples

opts <- c("GREY", "RED", "GREEN", "YELLOW", "BLUE", "PURPLE")
for (colour in opts) formatColoured(paste("Colour:", colour, "\n"), colour)
#> Colour: GREY 
#> Colour: RED 
#> Colour: GREEN 
#> Colour: YELLOW 
#> Colour: BLUE 
#> Colour: PURPLE 
#> 
formatColoured("my bold coloured text", bold = TRUE, cat = TRUE)
#> my bold coloured text