table.rows: Convert to HTML table rows.

View source: R/table1.R

table.rowsR Documentation

Convert to HTML table rows.

Description

Many functions exist in R to generate HTML tables. These functions are useful for generating HTML table fragments (rather than whole tables), which can then be used to build up complete tables. The first column my be used to label the rows of the table. Row labels, if specified, can have a special HTML class designated, which can be useful as a hook to customize their appearance using CSS. The same is true for the the first and last row of cells.

Usage

table.rows(
  x,
  row.labels = rownames(x),
  th = FALSE,
  class = NULL,
  rowlabelclass = "rowlabel",
  firstrowclass = "firstrow",
  lastrowclass = "lastrow",
  ...
)

table.data(
  x,
  row.labels = rownames(x),
  th = FALSE,
  class = NULL,
  rowlabelclass = "rowlabel",
  firstrowclass = "firstrow",
  lastrowclass = "lastrow",
  ...
)

Arguments

x

A vector or table-like structure (e.g. a data.frame or matrix).

row.labels

Values for the first column, typically used to label the row, or NULL to omit.

th

A logical. Should th tags be used rather than td?

class

HTML class attribute. Can be a single character, a vector or a matrix.

rowlabelclass

HTML class attribute for the row labels (i.e. first column).

firstrowclass

HTML class attribute for the first row of cells.

lastrowclass

HTML class attribute for the last row of cells.

...

Additional arguments.

Value

A character which contains an HTML table fragment.

Functions

  • table.data(): Convert to HTML table data (cells).

Examples

x <- matrix(signif_pad(exp(rnorm(5*5, 1, 1))), 5, 5)
table.data(x)
cat(table.rows(x, NULL))
cat(table.rows(x, LETTERS[1:nrow(x)]))
cat(table.rows(LETTERS[1:3], "Headings", th=TRUE))

table1 documentation built on Jan. 6, 2023, 5:07 p.m.