R/inline_text.tbl_summary.R
inline_text.tbl_summary.Rd
Extracts and returns statistics from a tbl_summary()
object for
inline reporting in an R markdown document. Detailed examples in the
inline_text vignette
# S3 method for class 'tbl_summary'
inline_text(
x,
variable,
column = NULL,
level = NULL,
pattern = NULL,
pvalue_fun = label_style_pvalue(prepend_p = TRUE),
...
)
# S3 method for class 'tbl_svysummary'
inline_text(
x,
variable,
column = NULL,
level = NULL,
pattern = NULL,
pvalue_fun = label_style_pvalue(prepend_p = TRUE),
...
)
(tbl_summary
)
Object created from tbl_summary()
or tbl_svysummary()
(tidy-select
)
A single variable name of statistic to present
(tidy-select
)
Column name to return from x$table_body
.
Can also pass the level of a by variable.
(string
)
Level of the variable to display for categorical variables.
Default is NULL
(string
)
String indicating the statistics to return.
Uses glue::glue()
formatting. Default is NULL
(function
)
Function to round and format p-values. Default is label_style_pvalue()
.
The function must have a numeric vector input, and return a string that is
the rounded/formatted p-value (e.g. pvalue_fun = label_style_pvalue(digits = 2)
).
These dots are for future extensions and must be empty.
A string reporting results from a gtsummary table
t1 <- trial |>
tbl_summary(by = trt, include = grade) |>
add_p()
inline_text(t1, variable = grade, level = "I", column = "Drug A", pattern = "{n}/{N} ({p}%)")
#> 35/98 (36%)
inline_text(t1, variable = grade, column = "p.value")
#> [1] "p=0.9"