outTable {reportRmd}R Documentation

Print tables to PDF/Latex HTML or Word

Description

Output the table nicely to whatever format is appropriate. This is the output function used by the rm_* printing functions.

Usage

outTable(
  tab,
  row.names = NULL,
  to_indent = numeric(0),
  bold_headers = TRUE,
  rows_bold = numeric(0),
  bold_cells = NULL,
  caption = NULL,
  digits = getOption("reportRmd.digits", 2),
  align,
  applyAttributes = TRUE,
  keep.rownames = FALSE,
  nicenames = TRUE,
  fontsize,
  chunk_label,
  format = NULL
)

Arguments

tab

a table to format

row.names

a string specifying the column name to assign to the rownames. If NULL (the default) then rownames are removed.

to_indent

numeric vector indicating which rows to indent in the first column.

bold_headers

boolean indicating if the column headers should be bolded

rows_bold

numeric vector indicating which rows to bold

bold_cells

array indices indicating which cells to bold. These will be in addition to rows bolded by rows_bold.

caption

table caption

digits

number of digits to round numeric columns to, wither a single number or a vector corresponding to the number of numeric columns in tab

align

string specifying column alignment, defaults to left alignment of the first column and right alignment of all other columns. The align argument accepts a single string with 'l' for left, 'c' for centre and 'r' for right, with no separations. For example, to set the left column to be centred, the middle column right-aligned and the right column left aligned use: align='crl'

applyAttributes

boolean indicating if the function should use to_indent and bold_cells formatting attributes. This will only work properly if the dimensions of the table output from rm_covsum, rm_uvsum etc haven't changed.

keep.rownames

should the row names be included in the output

nicenames

boolean indicating if you want to replace . and _ in strings with a space

fontsize

PDF/HTML output only, manually set the table fontsize

chunk_label

only used knitting to Word docs to allow cross-referencing

format

if specified ('html','latex') will override the global pandoc setting

Details

Entire rows can be bolded, or specific cells. Currently indentation refers to the first column only. By default, underscores in column names are converted to spaces. To disable this set rm_ to FALSE

Value

A character vector of the table source code, unless tableOnly=TRUE in which case a data frame is returned

Examples

# To make custom changes or change the fontsize in PDF/HTML
data("pembrolizumab")
tab <- rm_covsum(data=pembrolizumab,maincov = 'change_ctdna_group',
covs=c('age','sex','pdl1','tmb','l_size'),show.tests=TRUE,tableOnly = TRUE)
outTable(tab, fontsize=7)

# To bold columns with the variable names
rows_bold <- c(1,4,7,10,13)
outTable(tab,rows_bold = rows_bold)

# To bold the estimates for male/female
bold_cells <- as.matrix(expand.grid(5:6,1:ncol(tab)))
outTable(tab,bold_cells= bold_cells)

# Output the above table to HTML or LaTeX
#cat(outTable(tab=tab)) #Knits to specified global setting
#cat(outTable(tab, format="html"), file = "tab.html") #HTML output
#cat(outTable(tab, format="latex"), file = "tab.tex") #LaTeX output

[Package reportRmd version 0.1.0 Index]