printDebug | R Documentation |
print colorized output to R console
print colorized output to R console, inverted
print colorized output to HTML
printDebug(
...,
fgText = NULL,
fgDefault = getOption("jam.fgDefault", c("darkorange1", "dodgerblue")),
bgText = NULL,
fgTime = getOption("jam.fgTime", "cyan2"),
timeStamp = getOption("jam.timeStamp", TRUE),
comment = getOption("jam.comment", !htmlOut),
formatNumbers = getOption("jam.formatNumbers", TRUE),
trim = getOption("jam.trim", TRUE),
digits = getOption("jam.digits"),
nsmall = getOption("jam.nsmall", 0L),
justify = "left",
big.mark = getOption("jam.big.mark", ","),
small.mark = getOption("jam.small.mark", "."),
zero.print = NULL,
width = NULL,
doColor = getOption("jam.doColor"),
splitComments = FALSE,
collapse = getOption("jam.collapse", ""),
sep = getOption("jam.sep", ","),
doReset = NULL,
detectColors = TRUE,
dex = 2,
darkFactor = c(1, 1.5),
sFactor = c(1, 1.5),
lightMode = checkLightMode(),
Crange = getOption("jam.Crange"),
Lrange = getOption("jam.Lrange"),
removeNA = FALSE,
replaceNULL = NULL,
adjustRgb = getOption("jam.adjustRgb"),
byLine = FALSE,
verbose = FALSE,
indent = "",
keepNA = TRUE,
file = getOption("jam.file", ""),
append = getOption("jam.append", TRUE),
invert = getOption("jam.invert", FALSE),
htmlOut = getOption("jam.htmlOut", FALSE)
)
printDebugI(..., invert = TRUE)
printDebugHtml(..., htmlOut = TRUE, comment = FALSE)
... |
|
fgText |
one of two formats to define the foreground color for
elements in
|
bgText |
|
fgTime |
|
timeStamp |
|
comment |
|
formatNumbers |
|
trim , digits , nsmall , justify , big.mark , small.mark , zero.print , width |
arguments passed to |
doColor |
|
splitComments |
|
collapse |
|
sep |
|
doReset |
|
detectColors |
|
dex |
|
darkFactor , sFactor |
|
lightMode |
|
Crange , Lrange |
|
removeNA |
|
replaceNULL |
|
adjustRgb |
|
byLine |
|
verbose |
|
indent |
|
file |
argument passed to |
append |
|
invert |
|
htmlOut |
|
This function prints colorized output to the R console, with some rules for colorizing the output to help visually distinguish items.
The main intent is to use this function to print pretty debug messages, because color helps identify.
By default, output has the following configurable properties:
each line begins with a comment, controlled by default
comment=getOption("jam.comment", TRUE)
which by default uses "##"
,
but which can be defined to use a different prefix, or FALSE
for no prefix at all.
each line includes time and date stamp controlled by
timeStamp=getOption("jam.timeStamp", TRUE)
which by default includes the
current time and date.
each line formats numeric
values, controlled by
formatNumbers=getOption("jam.formatNumbers", TRUE)
, which determines
whether to apply arguments big.mark
and small.mark
to make numeric
values more readable.
each entry in ...
is printed with its own foreground color fgText
,
background color bgText
, with a slight lighter/darker dithering effect
to add minor visual distinction for multiple values.
Values in each vector
are concatenated by sep=","
by default.
Each list
is concatenated by collapse=""
by default.
Additional convenience rules:
For convenience, when the last ...
argument is a character
vector
of colors, it is assumed to be fgText
.
When the only entry in ...
is a character
vector of R colors,
the names are printed using the color vector for fgText
, or if no
names exist the colors are printed using the color vector for fgText
.
For printDebugI()
or invert=TRUE
, colors typically assigned to
fgText
are instead assigned to bgText
.
For very specific color assignments, fgText
and/or bgText
can be
defined as a list
of character
vectors of R colors, in which case
the list
overall is recycled to the length ...
to be printed,
and within each vector of ...
printed the corresponding color vector
is recycled to the length of that vector.
For use inside Rmarkdown .Rmd
documents, current recommendation is
to define the R output with results='asis'
like this:
\`\`\`{r block_name, results='asis'} # some R code here \`\`\`
Then define a global option to turn off the comment prefix in
printDebug()
: options("jam.comment"=FALSE)
For colorized text, it may require "html_output"
rendering of the
.Rmd
Rmarkdown file, as well as this option to enable HTML formatting
by printDebug()
: options("jam.htmlOut"=TRUE)
.
This function prints colorized output to the R console, using the
same logic as printDebug
except by default the color is inverted
so the default fgText
colors are applied to the background.
This function prints colorized output in HTML form, using the
same logic as printDebug
except by default the output is HTML.
The intended use is for RMarkdown with chunk option results='asis'
,
which causes the HTML code to be interpreted directly as HTML.
This function internally calls printDebug()
which then calls
make_html_styles()
. The text is surrounded by <span color='#FFFFFF'>
HTML formatting.
NULL
invisibly, this function is called for the side effect
of printing output using cat()
.
NULL
invisibly, this function is called for the side effect
of printing output using cat()
.
NULL
invisibly, this function is called for the side effect
of printing output using cat()
.
Other jam practical functions:
breakDensity()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
diff_functions()
,
exp2signed()
,
fileInfo()
,
fixYellow()
,
getAxisLabel()
,
handleArgsText()
,
heads()
,
isFALSEV()
,
isTRUEV()
,
jamba
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
make_html_styles()
,
make_styles()
,
match_unique()
,
mergeAllXY()
,
middle()
,
minorLogTicks()
,
newestFile()
,
renameColumn()
,
rmInfinite()
,
rmNAs()
,
rmNA()
,
rmNULL()
,
sclass()
,
sdim()
,
setPrompt()
Other jam practical functions:
breakDensity()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
diff_functions()
,
exp2signed()
,
fileInfo()
,
fixYellow()
,
getAxisLabel()
,
handleArgsText()
,
heads()
,
isFALSEV()
,
isTRUEV()
,
jamba
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
make_html_styles()
,
make_styles()
,
match_unique()
,
mergeAllXY()
,
middle()
,
minorLogTicks()
,
newestFile()
,
renameColumn()
,
rmInfinite()
,
rmNAs()
,
rmNA()
,
rmNULL()
,
sclass()
,
sdim()
,
setPrompt()
Other jam practical functions:
breakDensity()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
diff_functions()
,
exp2signed()
,
fileInfo()
,
fixYellow()
,
getAxisLabel()
,
handleArgsText()
,
heads()
,
isFALSEV()
,
isTRUEV()
,
jamba
,
jargs()
,
kable_coloring()
,
lldf()
,
log2signed()
,
make_html_styles()
,
make_styles()
,
match_unique()
,
mergeAllXY()
,
middle()
,
minorLogTicks()
,
newestFile()
,
renameColumn()
,
rmInfinite()
,
rmNAs()
,
rmNA()
,
rmNULL()
,
sclass()
,
sdim()
,
setPrompt()
printDebug("Testing ", "default ", "printDebug().");
printDebug("List of vectors:", c("one", "two", "three"));
# By default, there is no space between separate elements in `...`
printDebug("List of vectors:", c("one", "two", "three"),
c("four", "five", "six"));
# To add a space " " between elements, use collapse
printDebug("List of vectors:", c("one", "two", "three"),
c("four", "five", "six"), collapse=" ");
# slightly different style, one entry per line, indented:
printDebug("List of vectors:", c("one", "two", "three"),
c("four", "five", "six"), collapse="\n ");
# when a vector entirely contains recognized colors,
# the colors are used in the output
printDebug(c("red", "blue", "yellow"));
# When the vector contains colors, the names are used as the label
color_vector <- jamba::nameVector(c("red", "blue", "green","orange"),
c("group_A", "group_B", "group_C", "group_D"));
printDebug(color_vector);
# Remember the sister function that inverses the colors
printDebugI(color_vector);
printDebug(1:10, fgText="blue", dex=2);
printDebug(1:10, bgText="blue", dex=2);
printDebug(1:10, fgText="orange", dex=2);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.