
Report statistics from summary tables inline
Source: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
Usage
# 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),
...
)
Arguments
- x
(
tbl_summary
)
Object created fromtbl_summary()
ortbl_svysummary()
- variable
(
tidy-select
)
A single variable name of statistic to present- column
(
tidy-select
)
Column name to return fromx$table_body
. Can also pass the level of a by variable.- level
(
string
)
Level of the variable to display for categorical variables. Default isNULL
- pattern
(
string
)
String indicating the statistics to return. Usesglue::glue()
formatting. Default isNULL
- pvalue_fun
(
function
)
Function to round and format p-values. Default islabel_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.
Examples
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"