R/print_color.R

Defines functions print_colour print_color

Documented in print_color print_colour

#' @title Coloured console output
#' @name print_color
#'
#' @description Convenient function that allows coloured output in the console.
#'  Mainly implemented to reduce package dependencies.
#'
#' @param text The text to print.
#' @param color,colour Character vector, indicating the colour for printing.
#'   May be one of \code{"red"}, \code{"yellow"}, \code{"green"}, \code{"blue"},
#'   \code{"violet"}, \code{"cyan"} or \code{"grey"}. Formatting is also possible
#'   with \code{"bold"} or \code{"italic"}.
#'
#' @details This function prints \code{text} directly to the console using
#'   \code{cat()}, so no string is returned.
#'
#' @return Nothing.
#'
#' @examples
#' print_color("I'm blue dabedi dabedei", "blue")
#' @export
print_color <- function(text, color) {
  cat(.colour(colour = color, x = text))
}

#' @rdname print_color
#' @export
print_colour <- function(text, colour) {
  print_color(color = colour, text = text)
}

Try the insight package in your browser

Any scripts or data that you put into this service are public.

insight documentation built on Nov. 24, 2020, 5:15 p.m.