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 tbl_summary
inline_text(
x,
variable,
column = NULL,
level = NULL,
pattern = NULL,
pvalue_fun = NULL,
...
)
# S3 method for tbl_svysummary
inline_text(
x,
variable,
column = NULL,
level = NULL,
pattern = NULL,
pvalue_fun = NULL,
...
)
Object created from tbl_summary
Variable name of statistic to present
Column name to return from x$table_body
.
Can also pass the level of a by variable.
Level of the variable to display for categorical variables.
Can also specify the 'Unknown' row. Default is NULL
String indicating the statistics to return.
Uses glue::glue formatting. Default is pattern shown in tbl_summary()
output
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
A string reporting results from a gtsummary table
Other tbl_summary tools:
add_n.tbl_summary()
,
add_overall()
,
add_p.tbl_summary()
,
add_q()
,
add_stat_label()
,
bold_italicize_labels_levels
,
inline_text.tbl_survfit()
,
modify
,
separate_p_footnotes()
,
tbl_custom_summary()
,
tbl_merge()
,
tbl_split()
,
tbl_stack()
,
tbl_strata()
,
tbl_summary()
t1 <- trial[c("trt", "grade")] %>%
tbl_summary(by = trt) %>%
add_p()
inline_text(t1, variable = grade, level = "I", column = "Drug A", pattern = "{n}/{N} ({p})%")
#> [1] "35/98 (36)%"
inline_text(t1, variable = grade, column = "p.value")
#> [1] "p=0.9"