datasummary_df: Draw a table from a data.frame

Description Usage Arguments

View source: R/datasummary_df.R

Description

Draw a table from a data.frame

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
datasummary_df(
  data,
  output = "default",
  fmt = 2,
  align = NULL,
  hrule = NULL,
  title = NULL,
  notes = NULL,
  add_rows = NULL,
  add_columns = NULL,
  ...
)

Arguments

data

A data.frame (or tibble)

output

filename or object type (character string)

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

  • Supported object types: "default", "html", "markdown", "latex", "latex_tabular", "data.frame", "modelsummary_list", "gt", "kableExtra", "huxtable", "flextable", "jupyter".

  • To change the default output format, type options(modelsummary_default = "latex"), where latex can be any of the valid object types listed above.

  • 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 below for more information.

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.

align

A character string of length equal to the number of columns in the table. "lcr" means that the first column will be left-aligned, the 2nd column center-aligned, and the 3rd column right-aligned.

hrule

position of horizontal rules (integer vector)

title

string

notes

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

add_rows

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.

add_columns

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

...

all other arguments are passed through to the extractor and table-making functions. This allows users to pass arguments directly to modelsummary in order to affect the behavior of other functions behind the scenes. Examples include:

  • broom::tidy(exponentiate=TRUE) to exponentiate logistic regression

  • kableExtra::kbl(escape=FALSE) to avoid escaping math characters in kableExtra tables.

  • performance::model_performance(metrics="RMSE") to select goodness-of-fit statistics to extract using the performance package (must have set options(modelsummary_get="easystats") first).


modelsummary documentation built on June 17, 2021, 5:08 p.m.