makeStandardTable: Make standard table for rmarkdown reports

makeStandardTableR Documentation

Make standard table for rmarkdown reports

Description

Functions that will return tables used in reports.

Usage

mst(
  tab,
  col_names = colnames(tab),
  type = "latex",
  cap = "",
  label = "",
  digs = 0,
  align = NULL,
  fs = 8,
  lsd = FALSE
)

prettyTab(tab, add_totals = FALSE)

Arguments

tab

Data frame or matrix represetnting the table

col_names

Character vector with column names. Defaults colnames(tab)

type

Character string defining output, either 'html' or 'latex'. Default is 'latex'

cap

Character string with table caption. Empty string by default

label

Character string defining the label in case the table needs to be referenced elsewhere in the overall document. For instance, setting this to 'my_table' the corresponding inline rmarkdown reference to use is \@ref(tab:my_table). Please note that for this to work for both LaTex and HTML the bookdown document processing functions must be used, i.e. bookdown:pdf_document2() and bookdown::html_document2(), respectively. Default value is knitr::opts_current$get("label").

digs

Numeric number of digits to use. = by default

align

Character vector specifying column alignment in the LaTeX way, e.g. c("l", "c", "r") will align the first column to the left, center the second and right-aling the last one. Default is NULL in which case

fs

Numeric providing the font size. Only apply for LaTeX output. Default value is 8

lsd

Logical if table is to be scaled down. Only apply for LaTeX output. FALSE by default

add_totals

Logical if a column of sums is to be added to the table. Defaults to FALSE

Details

mst() creates RMarkdown code for creating standard tables.

prettyTab() creates a table with cells containing percentages of totals and observations optinally with a marginal row count

Value

Character string containing RMarkdown table code or an R data object

Examples

mst(tab = mtcars[1:10, ])
prettyTab(tab = as.matrix(mtcars[1:10, ]))

Rapporteket/NORIC documentation built on Feb. 15, 2024, 5:25 p.m.