diff --git a/R/sysdata.rda b/R/sysdata.rda index e4109dad6..de620cd84 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/tbl_survfit.R b/R/tbl_survfit.R index 2ec70b6d7..4a897cbbc 100644 --- a/R/tbl_survfit.R +++ b/R/tbl_survfit.R @@ -206,11 +206,12 @@ tbl_survfit.list <- function(x, ) } if (missing(statistic)) { - get_theme_element( - "tbl_survfit-arg:statistic", - default = - paste0("{estimate} ({conf.low}", get_theme_element("pkgwide-str:ci.sep", default = ", "), "{conf.high})") - ) + statistic <- + get_theme_element( + "tbl_survfit-arg:statistic", + default = + paste0("{estimate} ({conf.low}", get_theme_element("pkgwide-str:ci.sep", default = ", "), "{conf.high})") + ) } check_string(statistic) if (is_string(label)) label <- inject(everything() ~ !!label) diff --git a/data-raw/gtsummary_theme_elements.csv b/data-raw/gtsummary_theme_elements.csv index 0a99846fd..f28538676 100644 --- a/data-raw/gtsummary_theme_elements.csv +++ b/data-raw/gtsummary_theme_elements.csv @@ -1,84 +1,83 @@ -deprecated,fn,name,argument,desc,example -FALSE,add_global_p,add_global_p-str:type,FALSE,set argument default for `add_global_p.tbl_regression(type=)` and `add_global_p.tbl_uvregression(type=)`,"""II""" -FALSE,add_global_p,add_global_p-str:type,FALSE,"set argument default for `add_global_p.tbl_regression(type=)` and `add_global_p.tbl_uvregression(type=)`; default is `""III""`","""II""" -FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:pvalue_fun,TRUE,, -FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:source_note ,TRUE,, -FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:test,TRUE,, -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical,FALSE,default test for categorical/dichotomous variables,"""chisq.test""" -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical.group_by2,FALSE,default test for categorical/dichotomous grouped/correlated variables with a 2-level by variable,"""lme4""" -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical.low_count,FALSE,default test for categorical/dichotomous variables with minimum expected count <5,"""fisher.test""" -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous,FALSE,default test for continuous variables with a 3- or more level by variable,"""aov""" -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous.group_by2,FALSE,default test for continuous grouped/correlated variables with a 2-level by variable,"""lme4""" -FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous_by2,FALSE,default test for continuous variables with a 2-level by variable,"""t.test""" -TRUE,add_p.tbl_summary,add_p.tbl_summary-arg:pvalue_fun,TRUE,, -FALSE,add_p.tbl_summary,add_p.tbl_summary-arg:test,TRUE,, -FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-attr:test.categorical,FALSE,default test for categorical/dichotomous variables,"""svy.chisq.test""" -FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-attr:test.continuous,FALSE,default test for continuous variables,"""svy.wilcox.test""" -FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-arg:pvalue_fun,TRUE,, -FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-arg:test,TRUE,, -FALSE,add_q,add_q-arg:method,TRUE,, -FALSE,add_q,add_q-arg:pvalue_fun,TRUE,, -FALSE,add_stat_label,add_stat_label-arg:location,TRUE,, -FALSE,as_flex_table,as_flex_table-lst:addl_cmds,FALSE,"named list of expressions of {flextable} package commands inserted in the `as_flex_table()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_flex_table(x, return_calls = TRUE)` and check the names.","list(autofit = list(rlang::expr(flextable::font(fontname = ""Bodoni 72"", part = ""all"")), rlang::expr(flextable::fontsize(size = 8, part = ""all""))))" -FALSE,as_gt,as_gt-lst:addl_cmds,FALSE,"named list of expressions of {gt} package commands inserted in the `as_gt()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_gt(x, return_calls = TRUE)` and check the names.",list(tab_spanner = rlang::expr(gt::tab_options(table.font.size = 'small'))) -FALSE,as_hux_table,as_hux_table.gtsummary-lst:addl_cmds,FALSE,"named list of expressions of {huxtable} package commands inserted in the `as_hux_table()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_hux_table(x, return_calls = TRUE)` and check the names.", -FALSE,as_kable,as_kable-arg:dots,TRUE,"named list of arguments passed to `knitr::kable()`, which also applies to calls from `as_kable_extra()`","list(booktabs = TRUE, longtable = TRUE, linesep = """")" -FALSE,as_kable_extra,as_kable_extra-lst:addl_cmds,FALSE,"named list of expressions of {kableExtra} package commands inserted in the `as_kable_extra()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_kable_extra(x, return_calls = TRUE)` and check the names.", -FALSE,Package-wide,pkgwide-fn:prependpvalue_fun,FALSE,"function to style p-values throughout package that include a ""p"" prefix, e.g. ""p<0.001"" or ""p=0.12""; this is common in the `inline_text()` functions; default is `function(x) style_pvalue(x, prepend_p = TRUE)`","function(x) style_pvalue(x, digits = 2, prepend_p = TRUE)" -FALSE,Package-wide,pkgwide-fn:pvalue_fun,FALSE,function to style p-values throughout package; default is `style_pvalue`,"function(x) style_pvalue(x, digits = 2)" -FALSE,Package-wide,pkgwide-lgl:quiet,FALSE,logical indicating whether to suppress messages or not; default is `FALSE`, -FALSE,Package-wide,pkgwide-str:ci.sep,FALSE,"string indicating separator between upper and lower bounds of confidence intervals. Default is `"", ""`",""" to """ -FALSE,Package-wide,pkgwide-str:language,FALSE,"string indicating language; default is `""en""`","""es""" -FALSE,Package-wide,pkgwide-str:print_engine,FALSE,"string indicating the default print engine; default is `""gt""`","""flextable""" -FALSE,Package-wide,pkgwide-str:theme_name,FALSE,optional name of theme; name is printed when theme loaded,"""My Personal Theme""" -FALSE,Package-wide,pkgwide-fun:pre_conversion,FALSE,"function that is executed on the gtsummary object before it is converted with `as_gt()`, `as_flex_table()`, etc. Must be a function that can be run on every and any gtsummary object",bold_levels -FALSE,style_number,style_number-arg:big.mark,TRUE,, -FALSE,style_number,style_number-arg:decimal.mark,TRUE,, -FALSE,tbl_regression,tbl_regression-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_regression()` call,bold_labels -TRUE,tbl_regression,tbl_regression-chr:tidy_columns,FALSE,"character vector of columns from `tidy_fun=` tibble to print. 'estimate' column will always be printed. Select among columns 'conf.low', 'conf.high', 'std.error', 'statistic', or 'p.value'.","c(""std.error"", ""p.value"")" -FALSE,tbl_regression,tbl_regression-lst:tidy_plus_plus,FALSE,"Additional `tidy_plus_plus()` arguments. Cannot be one of `model=`, `tidy_fun=`, `exponentiate=`, `variable_labels=`, `show_single_row=`, `intercept=`, `include=`, `conf.level=`, `conf.int=`, or `strict=` as these are controlled by `tbl_regression()`. The default value for the additional arguments is `list(conf.int = TRUE, add_header_rows = TRUE, add_estimate_to_reference_rows = FALSE)`.","list(conf.int = TRUE, add_header_rows = TRUE, add_estimate_to_reference_rows = TRUE)" -FALSE,tbl_regression,tbl_regression-str:coef_header,FALSE,"string setting the default term for the beta coefficient column header; default is `""Beta""`","ifelse(exponentiate == TRUE, ""exp(coef)"", ""coef"")" -FALSE,tbl_regression,tbl_regression-str:ref_row_text,FALSE,string indicating the text to print on reference rows (default is an em-dash),"""Reference""" -FALSE,tbl_regression,tbl_regression-arg:conf.level,TRUE,, -FALSE,tbl_regression,tbl_regression-arg:conf.int,TRUE,, -FALSE,tbl_regression,tbl_regression-arg:estimate_fun ,TRUE,, -TRUE,tbl_regression,tbl_regression-arg:pvalue_fun ,TRUE,, -FALSE,tbl_regression,tbl_regression-arg:add_estimate_to_reference_rows,TRUE,, -FALSE,tbl_regression,tbl_regression-arg:tidy_fun ,TRUE,, -FALSE,tbl_stack,tbl_stack-str:group_header,FALSE,"string indicating the group column header used in `as_tibble()`, `as_flex_table()`, etc. where row headers are not supported; default is `""**Group**""`","""**Group Status**""" -FALSE,tbl_summary,tbl_summary-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_summary()` call,bold_labels -FALSE,tbl_summary,tbl_summary-fn:N_fun,FALSE,function to style integers. Currently questioning...THIS MAY BE REMOVED IN A FUTURE RELEASE. Use `style_number-arg:big.mark` and `style_number-arg:decimal.mark` instead.,"function(x) sprintf(""%.0f"", x)" -FALSE,tbl_summary,tbl_summary-fn:percent_fun,FALSE,function to style percentages; default is `style_percent`,function(x) style_percent(x) -FALSE,tbl_summary,tbl_summary-str:default_con_type,FALSE,"string indicating the default summary type for continuous variables; default is `""continuous""`; update to `""continuous2""` for multi-line summaries of continuous variables","""continuous2""" -FALSE,tbl_summary,tbl_summary-str:missing_stat,FALSE,"string indicating the statistic(s) to present on the missing row. The default is `""{N_miss}""`. Select among `c(""N_miss"", ""N_obs"", ""p_miss"", ""N_nonmiss"", ""p_nonmiss"")`","""{N_miss} ({p_miss}%)""" -FALSE,tbl_summary,tbl_summary-str:header-noby,FALSE,string indicating the statistic header when there is no by variable present,"""N={N}""" -FALSE,tbl_summary,tbl_summary-str:header-withby,FALSE,string indicating the statistic header when there is a by variable present,"""**{level}** \nN={n}""" -FALSE,tbl_summary,tbl_summary-arg:digits,TRUE,, -TRUE,tbl_summary,tbl_summary-arg:label,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:missing,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:missing_text,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:percent,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:sort,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:statistic,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:type,TRUE,, -FALSE,tbl_summary,tbl_summary-arg:value,TRUE,, -FALSE,tbl_survfit,tbl_survfit-arg:statistic,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_svysummary()` call,bold_labels -FALSE,tbl_svysummary,tbl_svysummary-str:header-noby,FALSE,string indicating the statistic header when there is no by variable present,"""N={N}""" -FALSE,tbl_svysummary,tbl_svysummary-str:header-withby,FALSE,string indicating the statistic header when there is a by variable present,"""**{level}** \nN={n}""" -FALSE,tbl_svysummary,tbl_svysummary-arg:digits,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:label,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:missing,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:missing_text,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:percent,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:sort,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:statistic,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:type,TRUE,, -FALSE,tbl_svysummary,tbl_svysummary-arg:value,TRUE,, -FALSE,add_difference,add_difference-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `add_difference()` call,bold_labels -FALSE,tbl_custom_summary,tbl_custom_summary-arg:digits,TRUE,, -FALSE,tbl_custom_summary,tbl_custom_summary-arg:label,TRUE,, -FALSE,tbl_custom_summary,tbl_custom_summary-arg:missing,TRUE,, -FALSE,tbl_custom_summary,tbl_custom_summary-arg:missing_text,TRUE,, -FALSE,tbl_custom_summary,tbl_custom_summary-arg:type,TRUE,, -FALSE,tbl_custom_summary,tbl_custom_summary-arg:value,TRUE,, +deprecated,fn,name,argument,desc,example +FALSE,add_global_p,add_global_p-str:type,FALSE,set argument default for `add_global_p.tbl_regression(type=)` and `add_global_p.tbl_uvregression(type=)`,"""II""" +FALSE,add_global_p,add_global_p-str:type,FALSE,"set argument default for `add_global_p.tbl_regression(type=)` and `add_global_p.tbl_uvregression(type=)`; default is `""III""`","""II""" +FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:pvalue_fun,TRUE,, +FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:source_note ,TRUE,, +FALSE,add_p.tbl_cross,add_p.tbl_cross-arg:test,TRUE,, +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical,FALSE,default test for categorical/dichotomous variables,"""chisq.test""" +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical.group_by2,FALSE,default test for categorical/dichotomous grouped/correlated variables with a 2-level by variable,"""lme4""" +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.categorical.low_count,FALSE,default test for categorical/dichotomous variables with minimum expected count <5,"""fisher.test""" +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous,FALSE,default test for continuous variables with a 3- or more level by variable,"""aov""" +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous.group_by2,FALSE,default test for continuous grouped/correlated variables with a 2-level by variable,"""lme4""" +FALSE,add_p.tbl_summary,add_p.tbl_summary-attr:test.continuous_by2,FALSE,default test for continuous variables with a 2-level by variable,"""t.test""" +TRUE,add_p.tbl_summary,add_p.tbl_summary-arg:pvalue_fun,TRUE,, +FALSE,add_p.tbl_summary,add_p.tbl_summary-arg:test,TRUE,, +FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-attr:test.categorical,FALSE,default test for categorical/dichotomous variables,"""svy.chisq.test""" +FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-attr:test.continuous,FALSE,default test for continuous variables,"""svy.wilcox.test""" +FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-arg:pvalue_fun,TRUE,, +FALSE,add_p.tbl_svysummary,add_p.tbl_svysummary-arg:test,TRUE,, +FALSE,add_q,add_q-arg:method,TRUE,, +FALSE,add_q,add_q-arg:pvalue_fun,TRUE,, +FALSE,add_stat_label,add_stat_label-arg:location,TRUE,, +FALSE,as_flex_table,as_flex_table-lst:addl_cmds,FALSE,"named list of expressions of {flextable} package commands inserted in the `as_flex_table()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_flex_table(x, return_calls = TRUE)` and check the names.","list(autofit = list(rlang::expr(flextable::font(fontname = ""Bodoni 72"", part = ""all"")), rlang::expr(flextable::fontsize(size = 8, part = ""all""))))" +FALSE,as_gt,as_gt-lst:addl_cmds,FALSE,"named list of expressions of {gt} package commands inserted in the `as_gt()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_gt(x, return_calls = TRUE)` and check the names.",list(tab_spanner = rlang::expr(gt::tab_options(table.font.size = 'small'))) +FALSE,as_hux_table,as_hux_table.gtsummary-lst:addl_cmds,FALSE,"named list of expressions of {huxtable} package commands inserted in the `as_hux_table()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_hux_table(x, return_calls = TRUE)` and check the names.", +FALSE,as_kable,as_kable-arg:dots,TRUE,"named list of arguments passed to `knitr::kable()`, which also applies to calls from `as_kable_extra()`","list(booktabs = TRUE, longtable = TRUE, linesep = """")" +FALSE,as_kable_extra,as_kable_extra-lst:addl_cmds,FALSE,"named list of expressions of {kableExtra} package commands inserted in the `as_kable_extra()` call; do not include the `data=` argument; the list of expressions is inserted after the named call, e.g. if the named list element is `""tab_spanner""` the expressions will be inserted after expressions named `""tab_spanner""`; to see the names of the expressions run `as_kable_extra(x, return_calls = TRUE)` and check the names.", +FALSE,Package-wide,pkgwide-fn:prependpvalue_fun,FALSE,"function to style p-values throughout package that include a ""p"" prefix, e.g. ""p<0.001"" or ""p=0.12""; this is common in the `inline_text()` functions; default is `function(x) style_pvalue(x, prepend_p = TRUE)`","function(x) style_pvalue(x, digits = 2, prepend_p = TRUE)" +FALSE,Package-wide,pkgwide-fn:pvalue_fun,FALSE,function to style p-values throughout package; default is `style_pvalue`,"function(x) style_pvalue(x, digits = 2)" +FALSE,Package-wide,pkgwide-str:ci.sep,FALSE,"string indicating separator between upper and lower bounds of confidence intervals. Default is `"", ""`",""" to """ +FALSE,Package-wide,pkgwide-str:language,FALSE,"string indicating language; default is `""en""`","""es""" +FALSE,Package-wide,pkgwide-str:print_engine,FALSE,"string indicating the default print engine; default is `""gt""`","""flextable""" +FALSE,Package-wide,pkgwide-str:theme_name,FALSE,optional name of theme; name is printed when theme loaded,"""My Personal Theme""" +FALSE,Package-wide,pkgwide-fun:pre_conversion,FALSE,"function that is executed on the gtsummary object before it is converted with `as_gt()`, `as_flex_table()`, etc. Must be a function that can be run on every and any gtsummary object",bold_levels +FALSE,style_number,style_number-arg:big.mark,TRUE,, +FALSE,style_number,style_number-arg:decimal.mark,TRUE,, +FALSE,tbl_regression,tbl_regression-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_regression()` call,bold_labels +TRUE,tbl_regression,tbl_regression-chr:tidy_columns,FALSE,"character vector of columns from `tidy_fun=` tibble to print. 'estimate' column will always be printed. Select among columns 'conf.low', 'conf.high', 'std.error', 'statistic', or 'p.value'.","c(""std.error"", ""p.value"")" +FALSE,tbl_regression,tbl_regression-lst:tidy_plus_plus,FALSE,"Additional `tidy_plus_plus()` arguments. Cannot be one of `model=`, `tidy_fun=`, `exponentiate=`, `variable_labels=`, `show_single_row=`, `intercept=`, `include=`, `conf.level=`, `conf.int=`, or `strict=` as these are controlled by `tbl_regression()`. The default value for the additional arguments is `list(conf.int = TRUE, add_header_rows = TRUE, add_estimate_to_reference_rows = FALSE)`.","list(conf.int = TRUE, add_header_rows = TRUE, add_estimate_to_reference_rows = TRUE)" +FALSE,tbl_regression,tbl_regression-str:coef_header,FALSE,"string setting the default term for the beta coefficient column header; default is `""Beta""`","ifelse(exponentiate == TRUE, ""exp(coef)"", ""coef"")" +FALSE,tbl_regression,tbl_regression-str:ref_row_text,FALSE,string indicating the text to print on reference rows (default is an em-dash),"""Reference""" +FALSE,tbl_regression,tbl_regression-arg:conf.level,TRUE,, +FALSE,tbl_regression,tbl_regression-arg:conf.int,TRUE,, +FALSE,tbl_regression,tbl_regression-arg:estimate_fun ,TRUE,, +TRUE,tbl_regression,tbl_regression-arg:pvalue_fun ,TRUE,, +FALSE,tbl_regression,tbl_regression-arg:add_estimate_to_reference_rows,TRUE,, +FALSE,tbl_regression,tbl_regression-arg:tidy_fun ,TRUE,, +FALSE,tbl_stack,tbl_stack-str:group_header,FALSE,"string indicating the group column header used in `as_tibble()`, `as_flex_table()`, etc. where row headers are not supported; default is `""**Group**""`","""**Group Status**""" +FALSE,tbl_summary,tbl_summary-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_summary()` call,bold_labels +FALSE,tbl_summary,tbl_summary-fn:N_fun,FALSE,function to style integers. Currently questioning...THIS MAY BE REMOVED IN A FUTURE RELEASE. Use `style_number-arg:big.mark` and `style_number-arg:decimal.mark` instead.,"function(x) sprintf(""%.0f"", x)" +FALSE,tbl_summary,tbl_summary-fn:percent_fun,FALSE,function to style percentages; default is `style_percent`,function(x) style_percent(x) +FALSE,tbl_summary,tbl_summary-str:default_con_type,FALSE,"string indicating the default summary type for continuous variables; default is `""continuous""`; update to `""continuous2""` for multi-line summaries of continuous variables","""continuous2""" +FALSE,tbl_summary,tbl_summary-str:missing_stat,FALSE,"string indicating the statistic(s) to present on the missing row. The default is `""{N_miss}""`. Select among `c(""N_miss"", ""N_obs"", ""p_miss"", ""N_nonmiss"", ""p_nonmiss"")`","""{N_miss} ({p_miss}%)""" +FALSE,tbl_summary,tbl_summary-str:header-noby,FALSE,string indicating the statistic header when there is no by variable present,"""N={N}""" +FALSE,tbl_summary,tbl_summary-str:header-withby,FALSE,string indicating the statistic header when there is a by variable present,"""**{level}** \nN={n}""" +FALSE,tbl_summary,tbl_summary-arg:digits,TRUE,, +TRUE,tbl_summary,tbl_summary-arg:label,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:missing,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:missing_text,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:percent,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:sort,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:statistic,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:type,TRUE,, +FALSE,tbl_summary,tbl_summary-arg:value,TRUE,, +FALSE,tbl_survfit,tbl_survfit-arg:statistic,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `tbl_svysummary()` call,bold_labels +FALSE,tbl_svysummary,tbl_svysummary-str:header-noby,FALSE,string indicating the statistic header when there is no by variable present,"""N={N}""" +FALSE,tbl_svysummary,tbl_svysummary-str:header-withby,FALSE,string indicating the statistic header when there is a by variable present,"""**{level}** \nN={n}""" +FALSE,tbl_svysummary,tbl_svysummary-arg:digits,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:label,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:missing,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:missing_text,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:percent,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:sort,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:statistic,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:type,TRUE,, +FALSE,tbl_svysummary,tbl_svysummary-arg:value,TRUE,, +FALSE,add_difference,add_difference-fn:addnl-fn-to-run,FALSE,a function that will be executed after at the end of each `add_difference()` call,bold_labels +FALSE,tbl_custom_summary,tbl_custom_summary-arg:digits,TRUE,, +FALSE,tbl_custom_summary,tbl_custom_summary-arg:label,TRUE,, +FALSE,tbl_custom_summary,tbl_custom_summary-arg:missing,TRUE,, +FALSE,tbl_custom_summary,tbl_custom_summary-arg:missing_text,TRUE,, +FALSE,tbl_custom_summary,tbl_custom_summary-arg:type,TRUE,, +FALSE,tbl_custom_summary,tbl_custom_summary-arg:value,TRUE,, \ No newline at end of file diff --git a/man/tests.Rd b/man/tests.Rd index ee1b2cde6..e649d16a6 100644 --- a/man/tests.Rd +++ b/man/tests.Rd @@ -14,93 +14,93 @@ calculate a p-value from \code{t.test()} assuming equal variance, use \section{\code{tbl_summary() \%>\% add_p()}}{ \tabular{llll}{ \strong{alias} \tab \strong{description} \tab \strong{pseudo-code} \tab \strong{details} \cr - \code{'t.test'} \tab t-test \tab \code{t.test(variable ~ as.factor(by), data = data, conf.level = 0.95, ...)} \tab \cr - \code{'mood.test'} \tab Mood two-sample test of scale \tab \code{mood.test(variable ~ as.factor(by), data = data, ...)} \tab Not to be confused with the Brown-Mood test of medians \cr - \code{'oneway.test'} \tab One-way ANOVA \tab \code{oneway.test(variable ~ as.factor(by), data = data, ...)} \tab \cr - \code{'kruskal.test'} \tab Kruskal-Wallis test \tab \code{kruskal.test(data[[variable]], as.factor(data[[by]]))} \tab \cr - \code{'wilcox.test'} \tab Wilcoxon rank-sum test \tab \code{wilcox.test(as.numeric(variable) ~ as.factor(by), data = data, conf.int = TRUE, conf.level = conf.level, ...)} \tab \cr - \code{'chisq.test'} \tab chi-square test of independence \tab \code{chisq.test(x = data[[variable]], y = as.factor(data[[by]]), ...)} \tab \cr - \code{'chisq.test.no.correct'} \tab chi-square test of independence \tab \code{chisq.test(x = data[[variable]], y = as.factor(data[[by]]), correct = FALSE)} \tab \cr - \code{'fisher.test'} \tab Fisher's exact test \tab \code{fisher.test(data[[variable]], as.factor(data[[by]]), conf.level = 0.95, ...)} \tab \cr - \code{'mcnemar.test'} \tab McNemar's test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); mcnemar.test(by_1, by_2, conf.level = 0.95, ...)} \tab \cr - \code{'mcnemar.test.wide'} \tab McNemar's test \tab \code{mcnemar.test(data[[variable]], data[[by]], conf.level = 0.95, ...)} \tab \cr - \code{'lme4'} \tab random intercept logistic regression \tab \verb{lme4::glmer(by ~ (1 \\UFF5C group), data, family = binomial) \%>\% anova(lme4::glmer(by ~ variable + (1 \\UFF5C group), data, family = binomial))} \tab \cr - \code{'paired.t.test'} \tab Paired t-test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); t.test(by_1, by_2, paired = TRUE, conf.level = 0.95, ...)} \tab \cr - \code{'paired.wilcox.test'} \tab Paired Wilcoxon rank-sum test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); wilcox.test(by_1, by_2, paired = TRUE, conf.int = TRUE, conf.level = 0.95, ...)} \tab \cr - \code{'prop.test'} \tab Test for equality of proportions \tab \code{prop.test(x, n, conf.level = 0.95, ...)} \tab \cr - \code{'ancova'} \tab ANCOVA \tab \code{lm(variable ~ by + adj.vars)} \tab \cr - \code{'emmeans'} \tab Estimated Marginal Means or LS-means \tab \code{lm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{glm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. When \code{group} is specified, \code{lme4::lmer()} and \code{lme4::glmer()} are used with the group as a random intercept. \cr + \code{"t.test"} \tab t-test \tab \code{t.test(variable ~ as.factor(by), data = data, conf.level = 0.95, ...)} \tab \cr + \code{"mood.test"} \tab Mood two-sample test of scale \tab \code{mood.test(variable ~ as.factor(by), data = data, ...)} \tab Not to be confused with the Brown-Mood test of medians \cr + \code{"oneway.test"} \tab One-way ANOVA \tab \code{oneway.test(variable ~ as.factor(by), data = data, ...)} \tab \cr + \code{"kruskal.test"} \tab Kruskal-Wallis test \tab \code{kruskal.test(data[[variable]], as.factor(data[[by]]))} \tab \cr + \code{"wilcox.test"} \tab Wilcoxon rank-sum test \tab \code{wilcox.test(as.numeric(variable) ~ as.factor(by), data = data, conf.int = TRUE, conf.level = conf.level, ...)} \tab \cr + \code{"chisq.test"} \tab chi-square test of independence \tab \code{chisq.test(x = data[[variable]], y = as.factor(data[[by]]), ...)} \tab \cr + \code{"chisq.test.no.correct"} \tab chi-square test of independence \tab \code{chisq.test(x = data[[variable]], y = as.factor(data[[by]]), correct = FALSE)} \tab \cr + \code{"fisher.test"} \tab Fisher's exact test \tab \code{fisher.test(data[[variable]], as.factor(data[[by]]), conf.level = 0.95, ...)} \tab \cr + \code{"mcnemar.test"} \tab McNemar's test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); mcnemar.test(by_1, by_2, conf.level = 0.95, ...)} \tab \cr + \code{"mcnemar.test.wide"} \tab McNemar's test \tab \code{mcnemar.test(data[[variable]], data[[by]], conf.level = 0.95, ...)} \tab \cr + \code{"lme4"} \tab random intercept logistic regression \tab \verb{lme4::glmer(by ~ (1 \\UFF5C group), data, family = binomial) \%>\% anova(lme4::glmer(by ~ variable + (1 \\UFF5C group), data, family = binomial))} \tab \cr + \code{"paired.t.test"} \tab Paired t-test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); t.test(by_1, by_2, paired = TRUE, conf.level = 0.95, ...)} \tab \cr + \code{"paired.wilcox.test"} \tab Paired Wilcoxon rank-sum test \tab \verb{tidyr::pivot_wider(id_cols = group, ...); wilcox.test(by_1, by_2, paired = TRUE, conf.int = TRUE, conf.level = 0.95, ...)} \tab \cr + \code{"prop.test"} \tab Test for equality of proportions \tab \code{prop.test(x, n, conf.level = 0.95, ...)} \tab \cr + \code{"ancova"} \tab ANCOVA \tab \code{lm(variable ~ by + adj.vars)} \tab \cr + \code{"emmeans"} \tab Estimated Marginal Means or LS-means \tab \code{lm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{glm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. When \code{group} is specified, \code{lme4::lmer()} and \code{lme4::glmer()} are used with the group as a random intercept. \cr } } \section{\code{tbl_svysummary() \%>\% add_p()}}{ \tabular{llll}{ \strong{alias} \tab \strong{description} \tab \strong{pseudo-code} \tab \strong{details} \cr - \code{'svy.t.test'} \tab t-test adapted to complex survey samples \tab \code{survey::svyttest(~variable + by, data)} \tab \cr - \code{'svy.wilcox.test'} \tab Wilcoxon rank-sum test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'wilcoxon')} \tab \cr - \code{'svy.kruskal.test'} \tab Kruskal-Wallis rank-sum test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'KruskalWallis')} \tab \cr - \code{'svy.vanderwaerden.test'} \tab van der Waerden's normal-scores test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'vanderWaerden')} \tab \cr - \code{'svy.median.test'} \tab Mood's test for the median for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'median')} \tab \cr - \code{'svy.chisq.test'} \tab chi-squared test with Rao & Scott's second-order correction \tab \code{survey::svychisq(~variable + by, data, statistic = 'F')} \tab \cr - \code{'svy.adj.chisq.test'} \tab chi-squared test adjusted by a design effect estimate \tab \code{survey::svychisq(~variable + by, data, statistic = 'Chisq')} \tab \cr - \code{'svy.wald.test'} \tab Wald test of independence for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'Wald')} \tab \cr - \code{'svy.adj.wald.test'} \tab adjusted Wald test of independence for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'adjWald')} \tab \cr - \code{'svy.lincom.test'} \tab test of independence using the exact asymptotic distribution for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'lincom')} \tab \cr - \code{'svy.saddlepoint.test'} \tab test of independence using a saddlepoint approximation for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'saddlepoint')} \tab \cr - \code{'emmeans'} \tab Estimated Marginal Means or LS-means \tab \code{survey::svyglm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{survey::svyglm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. \cr + \code{"svy.t.test"} \tab t-test adapted to complex survey samples \tab \code{survey::svyttest(~variable + by, data)} \tab \cr + \code{"svy.wilcox.test"} \tab Wilcoxon rank-sum test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'wilcoxon')} \tab \cr + \code{"svy.kruskal.test"} \tab Kruskal-Wallis rank-sum test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'KruskalWallis')} \tab \cr + \code{"svy.vanderwaerden.test"} \tab van der Waerden's normal-scores test for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'vanderWaerden')} \tab \cr + \code{"svy.median.test"} \tab Mood's test for the median for complex survey samples \tab \code{survey::svyranktest(~variable + by, data, test = 'median')} \tab \cr + \code{"svy.chisq.test"} \tab chi-squared test with Rao & Scott's second-order correction \tab \code{survey::svychisq(~variable + by, data, statistic = 'F')} \tab \cr + \code{"svy.adj.chisq.test"} \tab chi-squared test adjusted by a design effect estimate \tab \code{survey::svychisq(~variable + by, data, statistic = 'Chisq')} \tab \cr + \code{"svy.wald.test"} \tab Wald test of independence for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'Wald')} \tab \cr + \code{"svy.adj.wald.test"} \tab adjusted Wald test of independence for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'adjWald')} \tab \cr + \code{"svy.lincom.test"} \tab test of independence using the exact asymptotic distribution for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'lincom')} \tab \cr + \code{"svy.saddlepoint.test"} \tab test of independence using a saddlepoint approximation for complex survey samples \tab \code{survey::svychisq(~variable + by, data, statistic = 'saddlepoint')} \tab \cr + \code{"emmeans"} \tab Estimated Marginal Means or LS-means \tab \code{survey::svyglm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{survey::svyglm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. \cr } } \section{\code{tbl_survfit() \%>\% add_p()}}{ \tabular{lll}{ \strong{alias} \tab \strong{description} \tab \strong{pseudo-code} \cr - \code{'logrank'} \tab Log-rank test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 0)} \cr - \code{'tarone'} \tab Tarone-Ware test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 1.5)} \cr - \code{'petopeto_gehanwilcoxon'} \tab Peto & Peto modification of Gehan-Wilcoxon test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 1)} \cr - \code{'survdiff'} \tab G-rho family test \tab \code{survival::survdiff(Surv(.) ~ variable, data, ...)} \cr - \code{'coxph_lrt'} \tab Cox regression (LRT) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr - \code{'coxph_wald'} \tab Cox regression (Wald) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr - \code{'coxph_score'} \tab Cox regression (Score) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr + \code{"logrank"} \tab Log-rank test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 0)} \cr + \code{"tarone"} \tab Tarone-Ware test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 1.5)} \cr + \code{"petopeto_gehanwilcoxon"} \tab Peto & Peto modification of Gehan-Wilcoxon test \tab \code{survival::survdiff(Surv(.) ~ variable, data, rho = 1)} \cr + \code{"survdiff"} \tab G-rho family test \tab \code{survival::survdiff(Surv(.) ~ variable, data, ...)} \cr + \code{"coxph_lrt"} \tab Cox regression (LRT) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr + \code{"coxph_wald"} \tab Cox regression (Wald) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr + \code{"coxph_score"} \tab Cox regression (Score) \tab \code{survival::coxph(Surv(.) ~ variable, data, ...)} \cr } } \section{\code{tbl_continuous() \%>\% add_p()}}{ \tabular{lll}{ \strong{alias} \tab \strong{description} \tab \strong{pseudo-code} \cr - \code{'anova_2way'} \tab Two-way ANOVA \tab \code{lm(continuous_variable ~ by + variable)} \cr - \code{'t.test'} \tab t-test \tab \code{t.test(continuous_variable ~ as.factor(variable), data = data, conf.level = 0.95, ...)} \cr - \code{'oneway.test'} \tab One-way ANOVA \tab \code{oneway.test(continuous_variable ~ as.factor(variable), data = data)} \cr - \code{'kruskal.test'} \tab Kruskal-Wallis test \tab \code{kruskal.test(data[[continuous_variable]], as.factor(data[[variable]]))} \cr - \code{'wilcox.test'} \tab Wilcoxon rank-sum test \tab \code{wilcox.test(as.numeric(continuous_variable) ~ as.factor(variable), data = data, ...)} \cr - \code{'lme4'} \tab random intercept logistic regression \tab \verb{lme4::glmer(by ~ (1 \\UFF5C group), data, family = binomial) \%>\% anova(lme4::glmer(variable ~ continuous_variable + (1 \\UFF5C group), data, family = binomial))} \cr - \code{'ancova'} \tab ANCOVA \tab \code{lm(continuous_variable ~ variable + adj.vars)} \cr + \code{"anova_2way"} \tab Two-way ANOVA \tab \code{lm(continuous_variable ~ by + variable)} \cr + \code{"t.test"} \tab t-test \tab \code{t.test(continuous_variable ~ as.factor(variable), data = data, conf.level = 0.95, ...)} \cr + \code{"oneway.test"} \tab One-way ANOVA \tab \code{oneway.test(continuous_variable ~ as.factor(variable), data = data)} \cr + \code{"kruskal.test"} \tab Kruskal-Wallis test \tab \code{kruskal.test(data[[continuous_variable]], as.factor(data[[variable]]))} \cr + \code{"wilcox.test"} \tab Wilcoxon rank-sum test \tab \code{wilcox.test(as.numeric(continuous_variable) ~ as.factor(variable), data = data, ...)} \cr + \code{"lme4"} \tab random intercept logistic regression \tab \verb{lme4::glmer(by ~ (1 \\UFF5C group), data, family = binomial) \%>\% anova(lme4::glmer(variable ~ continuous_variable + (1 \\UFF5C group), data, family = binomial))} \cr + \code{"ancova"} \tab ANCOVA \tab \code{lm(continuous_variable ~ variable + adj.vars)} \cr } } \section{tbl_summary() \%>\% add_difference()}{ \tabular{lllll}{ \strong{alias} \tab \strong{description} \tab \strong{difference statistic} \tab \strong{pseudo-code} \tab \strong{details} \cr - \code{'t.test'} \tab t-test \tab mean difference \tab \code{t.test(variable ~ as.factor(by), data = data, conf.level = 0.95, ...)} \tab \cr - \code{'wilcox.test'} \tab Wilcoxon rank-sum test \tab \tab \code{wilcox.test(as.numeric(variable) ~ as.factor(by), data = data, conf.int = TRUE, conf.level = conf.level, ...)} \tab \cr - \code{'paired.t.test'} \tab Paired t-test \tab mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); t.test(by_1, by_2, paired = TRUE, conf.level = 0.95, ...)} \tab \cr - \code{'prop.test'} \tab Test for equality of proportions \tab rate difference \tab \code{prop.test(x, n, conf.level = 0.95, ...)} \tab \cr - \code{'ancova'} \tab ANCOVA \tab mean difference \tab \code{lm(variable ~ by + adj.vars)} \tab \cr - \code{'ancova_lme4'} \tab ANCOVA with random intercept \tab mean difference \tab \verb{lme4::lmer(variable ~ by + adj.vars + (1 \\UFF5C group), data)} \tab \cr - \code{'cohens_d'} \tab Cohen's D \tab standardized mean difference \tab \code{effectsize::cohens_d(variable ~ by, data, ci = conf.level, verbose = FALSE, ...)} \tab \cr - \code{'hedges_g'} \tab Hedge's G \tab standardized mean difference \tab \code{effectsize::hedges_g(variable ~ by, data, ci = conf.level, verbose = FALSE, ...)} \tab \cr - \code{'paired_cohens_d'} \tab Paired Cohen's D \tab standardized mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); effectsize::cohens_d(by_1, by_2, paired = TRUE, conf.level = 0.95, verbose = FALSE, ...)} \tab \cr - \code{'paired_hedges_g'} \tab Paired Hedge's G \tab standardized mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); effectsize::hedges_g(by_1, by_2, paired = TRUE, conf.level = 0.95, verbose = FALSE, ...)} \tab \cr - \code{'smd'} \tab Standardized Mean Difference \tab standardized mean difference \tab \code{smd::smd(x = data[[variable]], g = data[[by]], std.error = TRUE)} \tab \cr - \code{'emmeans'} \tab Estimated Marginal Means or LS-means \tab adjusted mean difference \tab \code{lm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{glm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. When \code{group} is specified, \code{lme4::lmer()} and \code{lme4::glmer()} are used with the group as a random intercept. \cr + \code{"t.test"} \tab t-test \tab mean difference \tab \code{t.test(variable ~ as.factor(by), data = data, conf.level = 0.95, ...)} \tab \cr + \code{"wilcox.test"} \tab Wilcoxon rank-sum test \tab \tab \code{wilcox.test(as.numeric(variable) ~ as.factor(by), data = data, conf.int = TRUE, conf.level = conf.level, ...)} \tab \cr + \code{"paired.t.test"} \tab Paired t-test \tab mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); t.test(by_1, by_2, paired = TRUE, conf.level = 0.95, ...)} \tab \cr + \code{"prop.test"} \tab Test for equality of proportions \tab rate difference \tab \code{prop.test(x, n, conf.level = 0.95, ...)} \tab \cr + \code{"ancova"} \tab ANCOVA \tab mean difference \tab \code{lm(variable ~ by + adj.vars)} \tab \cr + \code{"ancova_lme4"} \tab ANCOVA with random intercept \tab mean difference \tab \verb{lme4::lmer(variable ~ by + adj.vars + (1 \\UFF5C group), data)} \tab \cr + \code{"cohens_d"} \tab Cohen's D \tab standardized mean difference \tab \code{effectsize::cohens_d(variable ~ by, data, ci = conf.level, verbose = FALSE, ...)} \tab \cr + \code{"hedges_g"} \tab Hedge's G \tab standardized mean difference \tab \code{effectsize::hedges_g(variable ~ by, data, ci = conf.level, verbose = FALSE, ...)} \tab \cr + \code{"paired_cohens_d"} \tab Paired Cohen's D \tab standardized mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); effectsize::cohens_d(by_1, by_2, paired = TRUE, conf.level = 0.95, verbose = FALSE, ...)} \tab \cr + \code{"paired_hedges_g"} \tab Paired Hedge's G \tab standardized mean difference \tab \verb{tidyr::pivot_wider(id_cols = group, ...); effectsize::hedges_g(by_1, by_2, paired = TRUE, conf.level = 0.95, verbose = FALSE, ...)} \tab \cr + \code{"smd"} \tab Standardized Mean Difference \tab standardized mean difference \tab \code{smd::smd(x = data[[variable]], g = data[[by]], std.error = TRUE)} \tab \cr + \code{"emmeans"} \tab Estimated Marginal Means or LS-means \tab adjusted mean difference \tab \code{lm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{glm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. When \code{group} is specified, \code{lme4::lmer()} and \code{lme4::glmer()} are used with the group as a random intercept. \cr } } \section{tbl_svysummary() \%>\% add_difference()}{ \tabular{lllll}{ \strong{alias} \tab \strong{description} \tab \strong{difference statistic} \tab \strong{pseudo-code} \tab \strong{details} \cr - \code{'smd'} \tab Standardized Mean Difference \tab standardized mean difference \tab \code{smd::smd(x = variable, g = by, w = weights(data), std.error = TRUE)} \tab \cr - \code{'svy.t.test'} \tab t-test adapted to complex survey samples \tab \tab \code{survey::svyttest(~variable + by, data)} \tab \cr - \code{'emmeans'} \tab Estimated Marginal Means or LS-means \tab adjusted mean difference \tab \code{survey::svyglm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{survey::svyglm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. \cr + \code{"smd"} \tab Standardized Mean Difference \tab standardized mean difference \tab \code{smd::smd(x = variable, g = by, w = weights(data), std.error = TRUE)} \tab \cr + \code{"svy.t.test"} \tab t-test adapted to complex survey samples \tab \tab \code{survey::svyttest(~variable + by, data)} \tab \cr + \code{"emmeans"} \tab Estimated Marginal Means or LS-means \tab adjusted mean difference \tab \code{survey::svyglm(variable ~ by + adj.vars, data) \%>\% emmeans::emmeans(specs =~by) \%>\% emmeans::contrast(method = "pairwise") \%>\% summary(infer = TRUE, level = conf.level)} \tab When variable is binary, \code{survey::svyglm(family = binomial)} and \code{emmeans(regrid = "response")} arguments are used. \cr } } diff --git a/tests/testthat/test-theme_elements_gtsummary.R b/tests/testthat/test-theme_elements_gtsummary.R new file mode 100644 index 000000000..d196af1a4 --- /dev/null +++ b/tests/testthat/test-theme_elements_gtsummary.R @@ -0,0 +1,94 @@ +skip_on_cran() +skip_if_not(is_pkg_installed("survival")) + +# pkgwide-fn:prependpvalue_fun ------------------------------------------------- +test_that("pkgwide-fn:prependpvalue_fun", { + # works in `inline_text.tbl_summary()` + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-fn:prependpvalue_fun" = label_style_pvalue(digits = 3, prepend_p = TRUE)), + expr = + trial |> + tbl_summary(by = trt, include = age) |> + add_p() |> + inline_text(variable = age, column = "p.value") + ), + "p=0.718" + ) + + # works in `inline_text.tbl_cross()` + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-fn:prependpvalue_fun" = label_style_pvalue(digits = 3, prepend_p = TRUE)), + expr = + trial |> + tbl_cross(col = trt, row = grade) |> + add_p() |> + inline_text(col_level = "p.value") + ), + "p=0.871" + ) + + # works in `inline_text.tbl_regression()` + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-fn:prependpvalue_fun" = label_style_pvalue(digits = 3, prepend_p = TRUE)), + expr = + lm(marker ~ age, trial) |> + tbl_regression() |> + inline_text(variable = age, pattern = "{p.value}") + ), + "p=0.965" + ) + + # works in `inline_text.tbl_survfit()` + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-fn:prependpvalue_fun" = label_style_pvalue(digits = 3, prepend_p = TRUE)), + tbl_survfit( + survival::survfit(survival::Surv(ttdeath, death) ~ trt, trial), + times = c(12, 24), + label = ~"Treatment", + label_header = "**{time} Month**" + ) |> + add_p() |> + inline_text(column = p.value) + ), + "p=0.239" + ) +}) + +# pkgwide-str:ci.sep ----------------------------------------------------------- +test_that("pkgwide-str:ci.sep works", { + # works with add_difference() + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-str:ci.sep" = " --- "), + expr = + trial |> + tbl_summary(by = trt, include = age, missing = "no") |> + add_difference() |> + as_tibble(col_labels = FALSE) |> + dplyr::pull(conf.low) + ), + "-4.6 --- 3.7" + ) + + # works with `tbl_survfit()` + expect_equal( + with_gtsummary_theme( + x = list("pkgwide-str:ci.sep" = " --- "), + tbl_survfit( + survival::survfit(survival::Surv(ttdeath, death) ~ trt, trial), + times = 12, + label = ~"Treatment", + label_header = "**{time} Month**" + ) |> + as_tibble(col_labels = FALSE) |> + dplyr::pull(stat_1) |> + dplyr::last() + ), + "86% (80% --- 93%)" + ) +}) +