Learn R Programming

gtsummary (version 1.3.6)

add_glance_source_note: Add glance statistics

Description

experimental Add the statistics returned in broom::glance() as a table source note.

Usage

add_glance_source_note(
  x,
  include = everything(),
  label = NULL,
  fmt_fun = NULL,
  glance_fun = broom::glance,
  sep1 = " = ",
  sep2 = "; ",
  ...
)

Arguments

x

'tbl_regression' object

include

tidyselect list of statistics to include. Default is everything()

label

use to update statistic labels

fmt_fun

use to update default formatting function. Default is everything() ~ purrr::partial(style_sigfig, digits = 3)

glance_fun

function to calculate and return glance statistics. Default is broom::glance()

sep1

Separator between statistic name and statistic. Default is " = ", e.g. "R2 = 0.456"

sep2

Separator between statistics. Default is "; "

...

additional arguments passed to broom::glance()

Default Labels

The following statistics have set default labels when being printed. When there is no default, the label is the column name from broom::glance().

Statistic Name Default Label
r.squared R<U+00B2>
adj.r.squared Adjusted R<U+00B2>
p.value p-value
logLik log-likelihood
statistic Statistic
df.residual Residual df
null.deviance Null deviance
df.null Null df
nevent N events
concordance c-index
std.error.concordance c-index SE

Example Output

Example 1

Examples

Run this code
# NOT RUN {
# Example 1 ----------------------------------
add_glance_source_note_ex1 <-
  lm(age ~ marker + grade, trial) %>%
  tbl_regression() %>%
  add_glance_source_note(
    label = list(df  ~ "Degrees of Freedom", sigma ~ "\U03C3"),
    fmt_fun = df ~ style_number,
    include = c(r.squared, AIC, sigma, df)
  )
# }

Run the code above in your browser using DataLab