setOutputColors | R Documentation |
Set the output colors to be used if R is running in a terminal emulator. The terminal must be capable of displaying 256 colors. See a screenshot at colorout-package.
setOutputColors(normal = 40, negnum = 209, zero = 226,
number = 214, date = 179, string = 85,
const = 35, false = 203, true = 78,
infinite = 39, index = 30, stderror = 213,
warn = c(1, 16, 196), error = c(160, 231),
verbose = TRUE, zero.limit = NA)
normal |
Formating and color of normal text. |
negnum |
Formating and color of negative numbers. |
zero |
Formating and color of values being close to 0. |
number |
Formating and color of positive numbers. |
date |
Formating and color of dates and hours. For dates, the output format should be ‘YYYYxMMxDD’ or ‘DDxMMxYYYY’, where the separator x may equal '-' or '/'. For hours, the output format should be ‘HH:MM:SS’. |
string |
Formating and color of quoted text. |
const |
Formating and color of |
false |
Formating and color of |
true |
Formating and color of |
infinite |
Formating and color of |
index |
Formating and color of vector indexes. |
stderror |
Formating and color of text sent to stderr. |
warn |
Formating and color of warnings. |
error |
Formating and color of errors. |
verbose |
Logical value indicating whether to print colored words showing the result of the setup. |
zero.limit |
The limit below which a value is considered close to 0. If set,
the colorizing of zero and values near zero is enabled. You can also use
the function |
The function takes numeric vectors of at most three elements each. The three numbers indicate, respectively, formating, background color and foreground color. If a vector has only one element, the number will be used to set the foreground color; if it has two elements, they will be used to set the background and foreground colors.
If you pass a string as a color, it will be used as is. Thus, you should pass valid strings (please, see the true color example below). The string must have at most 63 characters.
The table below shows valid formating values (some formating codes do not work properly in some terminal emulators):
Value | Formating |
0 | No formating |
1 | Bold or bright |
2 | Faint |
3 | Italic or inverse |
4 | Underline |
5 | Blink slowly |
6 | Blink quickly |
7 | Invert |
The values of ANSI escape codes for 256 colors are different than the ones used in the function setOutputColors. Run show256Colors to to get a table of the 256 colors and their codes.
Messages are colored as errors and warnings if they start with "Error"
or "Warning"
(or their translations, if not running in an English
locale).
If the ‘TERM’ environment variable is "fbterm"
, fbterm escape
codes will be used instead of the ANSI ones and the format values will be
ignored.
NULL.
Jakson A. Aquino jalvesaq@gmail.com
# Color scheme for terminal emulator with only 8 colors:
setOutputColors(normal = 2, negnum = 3, zero = 3, number = 3,
date = 3, string = 6, const = 5, false = 5,
true = 2, infinite = 5, index = 2, stderror = 4,
warn = c(1, 0, 1), error = c(1, 7),
verbose = TRUE, zero.limit = NA)
# Color scheme for white background:
setOutputColors(normal = c(0, 0, 18), number = c(0, 0, 90),
negnum = c(0, 0, 88), date = c(0, 0, 53),
string = c(0, 0, 22), const = c(0, 0, 94), stderror = 52)
# Color schemes for black background:
setOutputColors(normal = 39, negnum = 183, zero = 114, number = 51,
date = 43, string = 79, const = 75, zero.limit = 0.1)
setOutputColors(normal = 202, number = 214, zero = 220, negnum = 209,
date = 184, string = 172, const = 179, zero.limit = 0.01)
setOutputColors(normal = 202, number = 214, zero = NA, negnum = 209,
date = 184, string = 172, const = 179, zero.limit = 0.01)
# True color example:
# The color code starts with "\x1b[" and ends with "m"
# 38;2 means "foreground"
# 48;2 means "background"
# valid values for red, green, and blue are integers between 0 and 255
setOutputColors(normal = "\x1b[38;2;0;200;0m", # red = 0; green = 200; blue = 0
negnum = "\x1b[38;2;255;200;0m",
zero = "\x1b[38;2;255;255;0m",
number = "\x1b[38;2;200;255;75m",
date = "\x1b[38;2;155;155;255m",
string = "\x1b[38;2;0;255;175m",
const = "\x1b[38;2;0;255;255m",
false = "\x1b[38;2;255;125;125m",
true = "\x1b[38;2;125;255;125m",
infinite = "\x1b[38;2;75;75;255m",
index = "\x1b[38;2;00;150;80m",
stderror = "\x1b[38;2;255;0;255m",
warn = "\x1b[38;2;255;0;0m",
error = "\x1b[38;2;255;255;255;48;2;255;0;0m",
zero.limit = 0.01)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.