CreateCustomTable: Display a html table with custom formatting

View source: R/createcustomtable.R

CreateCustomTableR Documentation

Display a html table with custom formatting

Description

Displays html table with custom formatting. This can be specified separately for each cell be specifying attributes or using CSS.

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,
  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 dim as x used for cell fills (1 denotes increase/green fill, -1 denotes decrease/red fill, 0 no fill)

sig.change.arrows

Matrix of same dim as x used for cell arrows (1 denotes increase/green up arrow, -1 denotes decrease/red down arrow, 0 no arrow)

sig.leader.circles

Matrix of same dim as x used 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 by attr(x, "statistic"). Ignored if x is not numeric.

format.show.pct.sign

Show percentage sign when format.type is "Percentage".

format.decimals

Controls number of decimal places shown in table cells. Ignored if x is 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 in x.

col.widths

specify column widths in % or px; Remaining width divided between remaining columns.

row.height

Height of table body rows. If NULL, then the rows are stretched to fill container.

col.header.height

Height of table header rows

num.header.rows

This is the number of rows from x which always be shown at the top of the window (only used when row.height is specified.

global.font.family

Character; font family for all occurrences of any font attribute in the table unless specified individually.

global.font.color

Global font color as a named color in character format (e.g. "black") or an a hex code.

font.size

Global font size of all elements in the table. This is provided for convenience but its overriden by the font sizes of specific components.

font.unit

One of "px" of "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

Color of all borders. Will be overriden if specific elements are set.

border.width

Width of borders (in pixels) in all cells. Will be overriden if specific elements are set.

border.collapse

Logical; whether the borders of adjacent cells should be shown as a single line or separate lines.

border.row.gap

Numeric; the space between the borders separating different rows. Only used if border.collapse is false.

border.column.gap

Numeric; the space between the borders separating different columns. Only used if border.collapse is 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

Background color of the cells in the table.

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 cell border in pixels. This is only used if the horizontal alignment is "left" or "right".

show.col.headers

Logical; whether to show column headers in the table. This will be ignored if x does not contain column names.

col.header.labels

A vector or comma-separated labels to override the column names of x.

col.header.fill

Background color of the column headers in the table.

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 of text in table 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 in the table. This will be ignored if x does not contain row names.

row.header.labels

A vector or comma-separated labels to override the column names of x.

row.header.fill

Background color of the row headers in the table.

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 of text in table 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.style

One of "normal" or "italic".

row.header.font.weight

One of "normal" or "bold".

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.fill

Background color of the row.spans in the table.

row.span.border.width

Width of border around table row.spans (in pixels).

row.span.border.color

Color of border around table row.spans,

row.span.align.horizontal

Horizontal alignment of text in table row.spans.

row.span.align.vertical

Vertical alignment of text in table row.spans.

row.span.font.family

Font family of text in table row.spans.

row.span.font.color

Font color of text in table row.spans.

row.span.font.size

Font size (in pixels) of text in table row.spans.

row.span.font.style

One of "normal" or "italic".

row.span.font.weight

One of "normal" or "bold".

row.span.pad

Space between text and cell border in pixels. This is only used if the horizontal alignment is "left" or "right".

col.span.fill

Background color of the col.spans in the table.

col.span.border.width

Width of border around table col.spans (in pixels).

col.span.border.color

Color of border around table col.spans,

col.span.align.horizontal

Horizontal alignment of text in table col.spans.

col.span.align.vertical

Vertical alignment of text in table col.spans.

col.span.font.family

Font family of text in table col.spans.

col.span.font.color

Font color of text in table col.spans.

col.span.font.size

Font size (in pixels) of text in table col.spans.

col.span.font.style

One of "normal" or "italic".

col.span.font.weight

One of "normal" or "bold".

col.span.pad

Space between text and cell border in pixels. This is only used if the horizontal alignment is "left" or "right".

corner

Contents of the corner cell, if row and column headers are used

corner.class

Class of the corner cell, if row and column headers are used

corner.fill

Background color of the corners in the table.

corner.border.width

Width of border around table corners (in pixels).

corner.border.color

Color of border around table corners,

corner.align.horizontal

Horizontal alignment of text in table corners.

corner.align.vertical

Vertical alignment of text in table corners.

corner.font.family

Font family of text in table corners.

corner.font.color

Font color of text in table corners.

corner.font.size

Font size (in pixels) of text in table corners.

corner.font.weight

One of "normal" or "bold".

corner.font.style

One of "normal" or "italic".

corner.pad

Space between text and cell border in pixels. This is only used if the horizontal alignment is "left" or "right".

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 text in table footer.

footer.align.vertical

Vertical alignment of text in table footer.

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 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

Whether to have banded rows

banded.cols

Whether to have banded columns

banded.odd.fill

Background of cells in odd rows or columns when banded.rows or banded.cols.

banded.even.fill

Background of cells in even rows or columns when banded.rows or banded.cols.

sig.fills.up

Cell color when sig.change.fills is used.

sig.fills.down

Cell color when sig.change.fills is used.

sig.fills.nothing

Cell color when sig.change.nothing is used.

sig.arrows.up

Color of up arrows when sig.change.arrows is used.

sig.arrows.down

Color of down arrows when sig.change.arrows is used.

circle.size

Size of circles when sig.leader.circles is used.

spacer.row

Indices of any blank divider rows

spacer.col

Indices of any blank divider 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.

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")))

Displayr/flipFormat documentation built on Feb. 26, 2024, 12:37 a.m.