The CreateCustomTable creates an HTML table with custom formatting using R. This article lists all of the available arguments for the function. Note that this is also the underlying function used with Visualization > Specialty Tables > Table with Custom Formatting so you can manually edit the R code of those outputs to customize some of these settings manually.
Usage
CreateCustomTable(
x,
sig.change.fills = NULL,
sig.change.arrows = NULL,
sig.leader.circles = NULL,
format.type = "Automatic",
format.show.pct.sign = TRUE,
format.decimals = 0,
suppress.nan = TRUE,
suppress.na = TRUE,
transpose = FALSE,
col.widths = if (is.null(rownames(x))) NULL else c("25%"),
row.height = NULL,
enable.x.scroll = FALSE,
enable.y.scroll = !is.null(row.height),
scrollbar.width = 17,
col.header.height = "35px",
num.header.rows = 0,
global.font.family = "Arial",
global.font.color = rgb(44, 44, 44, maxColorValue = 255),
font.size = 13,
font.unit = "px",
border.color = "#FFFFFF",
border.width = 1,
border.collapse = TRUE,
border.row.gap = 2,
border.column.gap = 2,
cell.prefix = "",
cell.suffix = "",
cell.fill = "#FFFFFF",
cell.border.width = border.width,
cell.border.color = border.color,
cell.align.horizontal = "center",
cell.align.vertical = "middle",
cell.font.family = global.font.family,
cell.font.color = global.font.color,
cell.font.size = font.size,
cell.font.weight = "normal",
cell.font.style = "normal",
cell.pad = 0,
show.col.headers = TRUE,
col.header.labels = NULL,
col.header.fill = "transparent",
col.header.border.width = border.width,
col.header.border.color = border.color,
col.header.align.horizontal = "center",
col.header.align.vertical = "middle",
col.header.font.family = global.font.family,
col.header.font.color = global.font.color,
col.header.font.size = font.size,
col.header.font.weight = "bold",
col.header.font.style = "normal",
col.header.pad = 0,
show.row.headers = TRUE,
row.header.labels = NULL,
row.header.fill = "transparent",
row.header.border.width = border.width,
row.header.border.color = col.header.border.color,
row.header.align.horizontal = "left",
row.header.align.vertical = "middle",
row.header.font.family = global.font.family,
row.header.font.color = global.font.color,
row.header.font.size = font.size,
row.header.font.style = "normal",
row.header.font.weight = "bold",
row.header.pad = 0,
row.span.fill = "transparent",
row.span.border.width = row.header.border.width,
row.span.border.color = row.header.border.color,
row.span.align.horizontal = "left",
row.span.align.vertical = "middle",
row.span.font.family = global.font.family,
row.span.font.color = global.font.color,
row.span.font.size = font.size,
row.span.font.style = "normal",
row.span.font.weight = "bold",
row.span.pad = 0,
col.span.fill = "transparent",
col.span.border.width = col.header.border.width,
col.span.border.color = col.header.border.color,
col.span.align.horizontal = "center",
col.span.align.vertical = "middle",
col.span.font.family = global.font.family,
col.span.font.color = global.font.color,
col.span.font.size = font.size,
col.span.font.style = "normal",
col.span.font.weight = "bold",
col.span.pad = 0,
corner = "",
corner.class = "",
corner.fill = "transparent",
corner.border.width = col.header.border.width,
corner.border.color = col.header.border.color,
corner.align.horizontal = "center",
corner.align.vertical = "middle",
corner.font.family = global.font.family,
corner.font.color = global.font.color,
corner.font.size = font.size,
corner.font.weight = "bold",
corner.font.style = "normal",
corner.pad = 0,
footer = "",
footer.height = paste0(footer.font.size + 5, font.unit),
footer.lineheight = "normal",
footer.fill = "transparent",
footer.align.horizontal = "center",
footer.align.vertical = "bottom",
footer.font.family = global.font.family,
footer.font.color = global.font.color,
footer.font.size = 8,
footer.font.weight = "normal",
footer.font.style = "normal",
col.header.classes = "",
row.header.classes = NULL,
col.classes = list(),
row.classes = list(),
banded.rows = FALSE,
banded.cols = FALSE,
banded.odd.fill = "rgb(250,250,250)",
banded.even.fill = "rgb(245,245,245)",
sig.fills.up = "rgb(195,255,199)",
sig.fills.down = "rgb(255,213,213)",
sig.fills.nothing = "rgb(255,255,255)",
sig.arrows.up = "rgb(0,172,62)",
sig.arrows.down = "rgb(192,0,0)",
circle.size = 35,
spacer.row = NULL,
spacer.col = NULL,
col.spans = NULL,
row.spans = NULL,
overflow = "hidden",
custom.css = "",
use.predefined.css = TRUE,
resizable = FALSE
)
Arguments
x: Matrix or data frame of contents to show in the table.sig.change.fills: Matrix of same dimensions asxused for cell fills (1 denotes increase/green fill, -1 denotes decrease/red fill, 0 no fill).sig.change.arrows: Matrix of same dimensions asxused for cell arrows (1 denotes increase/green up arrow, -1 denotes decrease/red down arrow, 0 no arrow).sig.leader.circles: Matrix of same dimensions asxused for 'leader' circles (2 denotes row leader, 1 denotes tied leaders, 0 denotes no circle).format.type: One of "Automatic", "Percentage" (multiply by 100 and add percentage sign) or "Numeric". When set to "Automatic", the format type will be determined byattr(x, "statistic"). Ignored ifxis not numeric.format.show.pct.sign: Logical; whether to show the percentage sign whenformat.typeis "Percentage".format.decimals: Number of decimal places shown in table cells. Ignored ifxis not numeric.suppress.nan: Whether to empty cells containing only NaN.suppress.na: Whether to empty cells containing only NA.transpose: Whether to switch rows and columns inx.col.widths: Specify column widths in % or px; remaining width divided between remaining columns.row.height: Height of table body rows. IfNULL, rows stretch to fill container.enable.x.scroll: If true, horizontal scrollbars are shown if the table is too wide. By default turned off for backwards compatibility.enable.y.scroll: If true, vertical scrollbar are shown. Mostly these would only be wanted if the number of rows is large and the height of the rows are fixed. But sometimes when there is a lot of text, the vertical scrollbars are also useful. By default only turned on when the row height is specified for backwards compatibility.scrollbar.width: The expected width of the scrollbars in pixels. We use this width to avoid hiding the right-side of the table when the vertical scrollbar is shown.col.header.height: Height of table header rows.num.header.rows: Number of rows fromxto always show at the top of the window (only used whenrow.heightis specified).global.font.family: Character; font family for all elements unless overridden.global.font.color: Global font color as a named color in character format (e.g. "black") or a hex code.font.size: Global font size of all elements in the table. This is provided for convenience but it's overridden by the font size of specific components.font.unit: Unit for font sizes ("px" or "pt"). By default all font sizes are specified in terms of pixels ("px"). But changing this to "pt" will mean that the font sizes will be in terms points ("pt"), which will be consistent with font sizes in text boxes.border.color: Default color of borders. Will be overridden if specific elements are set.border.width: Width of borders (in pixels). Will be overridden if specific elements are set.border.collapse: Logical; whether adjacent borders collapse into a single line.border.row.gap/border.column.gap: Numeric; spacing between rows/columns ifborder.collapseis false.cell.prefix: Character value/vector/matrix; that is prepended before the cell values.cell.suffix: Character value/vector/matrix; that is appended after the cell values.cell.fill: Character value/vector/matrix; of the background color of table cells.cell.border.width: Width of border around table cells (in pixels).cell.border.color: Color of border around table cells.cell.align.horizontal: Horizontal alignment of text in table cells.cell.align.vertical: Vertical alignment of text in table cells.cell.font.family: Font family of text in table cells.cell.font.color: Font color of text in table cells.cell.font.size: Font size (in pixels) of text in table cells.cell.font.weight: One of "normal" or "bold".cell.font.style: One of "normal" or "italic".cell.pad: Space between text and border in pixels. This is only used if the horizontal alignment is "left" or "right".show.col.headers: Logical; whether to show column headers (ignored ifxlacks names).col.header.labels: A vector or comma-separated labels to override the column names ofx.col.header.fill: Background color of the column headers.col.header.border.width: Width of border around table column headers (in pixels).col.header.border.color: Color of border around table column headers.col.header.align.horizontal: Horizontal alignment of text in table column headers.col.header.align.vertical: Vertical alignment for column headers.col.header.font.family: Font family of text in table column headers.col.header.font.color: Font color of text in table column headers.col.header.font.size: Font size (in pixels) of text in table column headers.col.header.font.weight: One of "normal" or "bold".col.header.font.style: One of "normal" or "italic".col.header.pad: Space between text and cell border in pixels. This is only used if the horizontal alignment is "left" or "right".show.row.headers: Logical; whether to show row headers (ignored ifxlacks row names).row.header.labels: A vector or comma-separated labels to override the row names ofx.row.header.fill: Background color of the row headers.row.header.border.width: Width of border around table row headers (in pixels).row.header.border.color: Color of border around table row headers.row.header.align.horizontal: Horizontal alignment of text in table row headers.row.header.align.vertical: Vertical alignment for row headers.row.header.font.family: Font family of text in table row headers.row.header.font.color: Font color of text in table row headers.row.header.font.size: Font size (in pixels) of text in table row headers.row.header.font.weight: One of "normal" or "bold".row.header.font.style: One of "normal" or "italic".row.header.pad: Space between text and cell border in pixels. This is only used if the horizontal alignment is "left" or "right".row.span.*andcol.span.*: *Same styling options (.fill,.border.width, etc) asrow.header.andcol.header.above.corner: Contents of the corner cell if row and column headers are used.corner.class: Class of the corner cell, if row and columns headers are used.corner.*: *Same styling options (.fill,.border.width, etc) asrow.header.andcol.header.above.footer: Optional text shown as a footer below the table.footer.height: Height of the footer (ignored if no text in footer).footer.lineheight: Controls spacing between the lines of text in the footer. It can be specified in multiple ways but as a unitless number it is applied as a multiple to the font size.footer.fill: Background color of the footer in the table.footer.align.horizontal: Horizontal alignment of footer text.footer.align.vertical: Vertical alignment of footer text.footer.font.family: Font family of text in table footer.footer.font.color: Font color of text in table footer.footer.font.size: Font size (in pixels) of text in table footer.footer.font.weight: One of "normal" or "bold".footer.font.style: One of "normal" or "italic".col.header.classes: CSS classes of column headers. The class definition should be added to custom.css. This overrides col.header.fill, col.header.border, col.header.font, col.header.align, etc.row.header.classes: CSS classes of column headers. This overrides row.header.fill, row.header.border, row.header.font, row.header.align, etc.col.classes: Any specific column classes to apply. e.g. list(list(ix=3, class="bluefill")) will cause column 3 to have class "bluefill".row.classes: Any specific row classes to apply.banded.rows/banded.cols: Whether to have banded rows or columns.banded.odd.fill: Background of cells in odd rows or columns when usingbanded.rowsorbanded.cols.banded.even.fill: Background of cells in even rows or columns when usingbanded.rowsorbanded.cols.sig.fills.up,sig.fills.down,sig.fills.nothing: Cell color whensig.change.fillsis used for significant indicators.sig.arrows.up,sig.arrows.down: Arrow color whensig.change.arrowsis used for significant indicators.circle.size: Size of circles whensig.leader.circlesis used.spacer.row/spacer.col: Indices for any blank divider rows/columns.col.spans: List of column spans to place above the column headers:
list(list(width=,label=,class=), list(width=,label=,class=))row.spans: List of row spans to place left of the row headers:
list(list(height=,label=,class=), list(height=,label=,class=)overflow: Determines behaviour of text that is too long to fit in the table cells. By default, it is set to "hidden" but change to "visible" to show overflow text.custom.css: Any custom CSS to add to the<style>header of the html (e.g. defining nth-child logic or custom classes not included in the CSS function). When this is used, the resulting widget is inclosed inside an iframe to avoid affecting other widgets.use.predefined.css: Logical; whether to include CSS definitions for classes rh, rhclean, simpleheader, simpleheaderclean, nsline, subjourneyHeader, subjourneySubHeader white, spacer. This is included for backwards compatibiliy but it is probably safer to omit this is not used.resizable: Allow column widths to be resizeable by dragging with mouse.
Description
Displays an HTML table with custom formatting. You can specify formatting for each cell individually or apply CSS classes globally. Options include controlling fonts, colors, borders, alignment, banded rows/columns, significance fills, and more.
Examples
xx <- structure(1:24,
.Dim = c(4L, 6L),
.Dimnames = list(c("a", "b", "c", "d"),
c("A", "B", "C", "D", "E", "F")))
CreateCustomTable(xx,
row.spans=list(list(height=2, label="AA"),
list(height=1, label="BB"),
list(height=1, label="CC")))