Learn R Programming

gtsummary (version 1.2.1)

inline_text.tbl_summary: Report statistics from summary tables inline

Description

Extracts and returns statistics from a tbl_summary object for inline reporting in an R markdown document. Detailed examples in the tbl_summary vignette

Usage

# S3 method for tbl_summary
inline_text(x, variable, level = NULL,
  column = ifelse(is.null(x$by), "stat_0", stop("Must specify column")),
  pvalue_fun = function(x) style_pvalue(x, prepend_p = TRUE), ...)

Arguments

x

Object created from tbl_summary

variable

Variable name of statistic to present

level

Level of the variable to display for categorical variables. Can also specify the 'Unknown' row. Default is NULL

column

Column name to return from x$table_body. Can also pass the level of a by variable.

pvalue_fun

Function to round and format p-values. Default is style_pvalue. The function must have a numeric vector input (the numeric, exact p-value), and return a string that is the rounded/formatted p-value (e.g. pvalue_fun = function(x) style_pvalue(x, digits = 2) or equivalently, purrr::partial(style_pvalue, digits = 2)).

...

Not used

Value

A string reporting results from a gtsummary table

See Also

Other tbl_summary tools: add_n, add_overall, add_p, add_q.tbl_summary, add_stat_label, bold_italicize_labels_levels, bold_p.tbl_summary, modify_header, sort_p.tbl_summary, tbl_summary

Examples

Run this code
# NOT RUN {
t1 <- tbl_summary(trial)
t2 <- tbl_summary(trial, by = trt) %>% add_p()

inline_text(t1, variable = "age")
inline_text(t2, variable = "grade", level = "I", column = "Drug")
inline_text(t2, variable = "grade", column = "p.value")
# }

Run the code above in your browser using DataLab