Draw a table from a data.frame

## Usage

datasummary_df(
data,
output = "default",
fmt = 2,
align = NULL,
hrule = NULL,
title = NULL,
notes = NULL,
escape = TRUE,
...
)

## Arguments

data

A data.frame (or tibble)

output

filename or object type (character string)

• Supported filename extensions: .docx, .html, .tex, .md, .txt, .png, .jpg.

• Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "gt", "kableExtra", "huxtable", "flextable", "jupyter". The "modelsummary_list" value produces a lightweight object which can be saved and fed back to the modelsummary function.

• Warning: Users should not supply a file name to the output argument if they intend to customize the table with external packages. See the 'Details' section.

• LaTeX compilation requires the booktabs and siunitx packages, but siunitx can be disabled or replaced with global options. See the 'Details' section.

• The default output formats and table-making packages can be modified with global options. See the 'Details' section.

fmt

determines how to format numeric values

• integer: the number of digits to keep after the period format(round(x, fmt), nsmall=fmt)

• character: passed to the sprintf function (e.g., '%.3f' keeps 3 digits with trailing zero). See ?sprintf

• function: returns a formatted character string.

• NULL: does not format numbers, which allows users to include function in the "glue" strings in the estimate and statistic arguments.

align

A string with a number of characters equal to the number of columns in the table (e.g., align = "lcc"). Valid characters: l, c, r, d.

• "l": left-aligned column

• "c": centered column

• "r": right-aligned column

• "d": dot-aligned column. Only supported for LaTeX/PDF tables produced by kableExtra. These commands must appear in the LaTeX preamble (they are added automatically when compiling Rmarkdown documents to PDF):

• \usepackage{booktabs}

• \usepackage{siunitx}

• \newcolumntype{d}{S[input-symbols = ()]}

hrule

position of horizontal rules (integer vector)

title

string

notes

list or vector of notes to append to the bottom of the table.

a data.frame (or tibble) with the same number of columns as your main table. By default, rows are appended to the bottom of the table. You can define a "position" attribute of integers to set the row positions. See Examples section below.

a data.frame (or tibble) with the same number of rows as your main table.

escape

boolean TRUE escapes or substitutes LaTeX/HTML characters which could prevent the file from compiling/displaying. This setting does not affect captions or notes.

...

all other arguments are passed through to the table-making functions kableExtra::kbl or gt::gt, depending on the output argument. This allows users to pass arguments directly to datasummary in order to affect the behavior of other functions behind the scenes.

## References

Arel-Bundock V (2022). “modelsummary: Data and Model Summaries in R.” Journal of Statistical Software, 103(1), 1-23. doi:10.18637/jss.v103.i01 .'