chr.color | R Documentation |
This function adds color and style to output texts on terminals that support
'ANSI' color and highlight codes that can be printed by using the cat
function.
chr.color(x, color = c("black", "red", "green", "yellow", "blue", "violet",
"cyan", "white", "gray", "b.red", "b.green", "b.yellow",
"b.blue", "b.violet", "b.cyan", "b.white"),
bg = c("none", "black", "red", "green", "yellow", "blue", "violet",
"cyan", "white"),
style = c("regular", "bold", "italic", "underline"), check = TRUE)
x |
a character vector. |
color |
a character string indicating the text color, e.g., |
bg |
a character string indicating the background color of the text,
e.g., |
style |
a character vector indicating the font style, i.e., |
check |
logical: if |
Returns a character vector.
This function is based on functions provided in the crayon package by Gábor Csárdi.
Takuya Yanagida
Csárdi G (2022). crayon: Colored Terminal Output. R package version 1.5.2, https://CRAN.R-project.org/package=crayon
## Not run:
# Example 1:
cat(chr.color("Text in red.", color = "red"))
# Example 2:
cat(chr.color("Text in blue with green background.",
color = "blue", bg = "yellow"))
# Example 3a:
cat(chr.color("Text in boldface.", style = "bold"))
# Example 3b:
cat(chr.color("Text in boldface and italic.", style = c("bold", "italic")))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.