kable_coloring | R Documentation |
Extend kableExtra colorization of Rmarkdown tables
kable_coloring(
df,
colorSub = NULL,
background_as_tile = TRUE,
color_cells = TRUE,
row_color_by = NULL,
sep = "_",
border_left = "1px solid #DDDDDD",
border_right = FALSE,
extra_css = "white-space: nowrap;",
format = "html",
format.args = list(trim = TRUE, big.mark = ","),
row.names = NA,
align = NULL,
return_type = c("kable", "data.frame"),
verbose = FALSE,
...
)
df |
|
colorSub |
one of the following inputs:
|
background_as_tile |
|
color_cells |
|
row_color_by |
|
sep |
|
border_left , border_right , extra_css |
|
format |
|
format.args |
|
row.names |
|
align |
|
return_type |
|
verbose |
boolean indicating whether to print verbose output. |
... |
additional arguments are passed to |
This function extends the kableExtra
package, and is only
available for use if the kableExtra
package is installed. It is
intended to allow specific color assignment of elements in a
data.frame, but otherwise uses the kableExtra
functions to
apply those colors.
The use case is to provide colorized HTML output for RMarkdown,
it has not been tested with other format
output.
The argument colorSub
accepts:
character
vector input where
names should match column values
function
that accepts column values and returns a character
vector of colors of equal length
list
input where names should match colnames(df)
, and where
each list element should contain either a character
vector, or
function
as described above.
object with class c("kableExtra", "knitr_kable")
by default
when return_type="kable"
, suitable to render inside an RMarkdown
or HTML context. Or returns data.frame
when return_type="data.frame"
.
data.frame
or class with "kableExtra"
dependent upon the
return_type
argument. Note that even the data.frame
returned
will have colors encoded into each cell using HTML.
Other jam color functions:
alpha2col()
,
applyCLrange()
,
col2alpha()
,
col2hcl()
,
col2hsl()
,
col2hsv()
,
color2gradient()
,
fixYellowHue()
,
fixYellow()
,
getColorRamp()
,
hcl2col()
,
hsl2col()
,
hsv2col()
,
isColor()
,
makeColorDarker()
,
make_html_styles()
,
make_styles()
,
rgb2col()
,
setCLranges()
,
setTextContrastColor()
,
showColors()
,
unalpha()
,
warpRamp()
Other jam practical functions:
breakDensity()
,
checkLightMode()
,
check_pkg_installed()
,
colNum2excelName()
,
color_dither()
,
diff_functions()
,
exp2signed()
,
fileInfo()
,
fixYellow()
,
getAxisLabel()
,
handleArgsText()
,
heads()
,
isFALSEV()
,
isTRUEV()
,
jamba
,
jargs()
,
lldf()
,
log2signed()
,
make_html_styles()
,
make_styles()
,
match_unique()
,
mergeAllXY()
,
middle()
,
minorLogTicks()
,
newestFile()
,
printDebug()
,
renameColumn()
,
rmInfinite()
,
rmNAs()
,
rmNA()
,
rmNULL()
,
sclass()
,
sdim()
,
setPrompt()
new_colorSub <- list(
column_A=nameVector(rainbow(5), LETTERS[1:5]),
column_B=nameVector(rev(rainbow(5)), LETTERS[1:5]),
column_C=circlize::colorRamp2(
colors=getColorRamp("Reds", n=6),
breaks=0:5 * 1000))
testdf <- data.frame(column_A=LETTERS[1:5],
row.names=LETTERS[1:5],
column_B=LETTERS[1:5],
column_C=1:5 * 1000)
# kableExtra output with colored tiles inside table cells
kdf1 <- kable_coloring(
df=testdf,
colorSub=new_colorSub)
print(class(kdf1));
kdf1;
# kableExtra output with colored rows
kdf2 <- kable_coloring(
row_color_by=3,
df=testdf,
colorSub=new_colorSub)
class(kdf2);
kdf2;
# data.frame output is a regular data.frame with HTML contents
kdf3 <- kable_coloring(
return_type="data.frame",
df=testdf,
colorSub=new_colorSub)
kdf3;
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.