textab: Convert a data frame to a LaTeX table

View source: R/textab.R

textabR Documentation

Convert a data frame to a LaTeX table

Description

Converts a data frame to LaTeX or HTML. If bold.which is given it should be a logical matrix specifying bold cells. Otherwise: in each column or row with numeric data, the maximum or minimum value is set bold; bold.max can have entries for each column/row, NA means skip.

Usage

textab(
  x,
  file = "",
  type = c("latex", "html"),
  caption = NULL,
  label = NULL,
  align = NULL,
  digits = NULL,
  display = NULL,
  auto = FALSE,
  bold.which = NULL,
  bold.each = c("column", "row"),
  bold.max = NA,
  NA.string = "",
  sanitize.text.function = force,
  sanitize.rownames.function = NULL,
  sanitize.colnames.function = NULL,
  ...
)

Arguments

x

a data frame.

file

using this argument, the resulting table is written to a file rather than to the R prompt. The file name can be specified as a character string.

type

type of table to produce. Possible values for type are "latex" or "html".

caption

argument passed to xtable.

label

argument passed to xtable.

align

argument passed to xtable.

digits

argument passed to xtable.

display

argument passed to xtable.

auto

argument passed to xtable.

bold.which

logical matrix specifying bold cells.

bold.each

axis along which to compute the max/min. Possible values for each are "row" or "column".

bold.max

whether to boldify maximum values (TRUE) or minimum values (FALSE).

NA.string

string to be used for missing values in table entries.

sanitize.text.function

argument passed to print.xtable.

sanitize.rownames.function

argument passed to print.xtable.

sanitize.colnames.function

argument passed to print.xtable.

...

additional arguments passed to print.xtable.

Note

The code is adopted from https://gist.github.com/floybix/452201

Examples

x <- tail(iris[,1:4])
textab(x)
textab(x, bold.each = "column", bold.max = c(FALSE, NA, NA, TRUE))
textab(x, bold.each = "row", bold.max = FALSE)
textab(x, bold.which = x >= 6.5)


eguidotti/eap documentation built on Sept. 4, 2024, 3:43 a.m.