Skip to content

Commit

Permalink
1994 update standalone@main (#2046)
Browse files Browse the repository at this point in the history
* redirect standalone scripts to pull from insightsengineering repo

* remove "reference_pkg" argument for package install checks.

* add "ref = cardx" argument

* missed file
  • Loading branch information
ayogasekaram authored Oct 23, 2024
1 parent 2a05ed9 commit 901cc30
Show file tree
Hide file tree
Showing 129 changed files with 320 additions and 258 deletions.
2 changes: 1 addition & 1 deletion R/add_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#' @return gtsummary table
#' @name add_ci
#'
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed("cardx") && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' # Example 1 ----------------------------------
#' trial |>
#' tbl_summary(
Expand Down
2 changes: 1 addition & 1 deletion R/add_ci.tbl_svysummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @export
#' @name add_ci.tbl_svysummary
#'
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survey"), reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survey")) && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' data(api, package = "survey")
#' survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) |>
#' tbl_svysummary(
Expand Down
2 changes: 1 addition & 1 deletion R/add_difference.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_difference <- function(x, ...) {
#' @export
#' @return a gtsummary table of class `"tbl_summary"`
#'
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed("cardx") && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' # Example 1 ----------------------------------
#' trial |>
#' select(trt, age, marker, response, death) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/add_difference.tbl_svysummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' @export
#' @return a gtsummary table of class `"tbl_summary"`
#'
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed("cardx") && gtsummary:::is_pkg_installed("broom", ref = "cardx")
add_difference.tbl_svysummary <- function(x,
test = NULL,
group = NULL,
Expand Down
4 changes: 2 additions & 2 deletions R/add_glance.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ add_glance_table <- function(x,
# check inputs ---------------------------------------------------------------
set_cli_abort_call()
updated_call_list <- c(x$call_list, list(add_glance_table = match.call()))
check_pkg_installed("broom", reference_pkg = "gtsummary")
check_pkg_installed("broom")
check_not_missing(x)
check_class(x, "tbl_regression")

Expand Down Expand Up @@ -134,7 +134,7 @@ add_glance_source_note <- function(x,
# check inputs ---------------------------------------------------------------
set_cli_abort_call()
updated_call_list <- c(x$call_list, list(add_glance_source_note = match.call()))
check_pkg_installed("broom", reference_pkg = "gtsummary")
check_pkg_installed("broom")
check_not_missing(x)
check_class(x, "tbl_regression")
text_interpret <- arg_match(text_interpret)
Expand Down
2 changes: 1 addition & 1 deletion R/add_global_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' @author Daniel D. Sjoberg
#' @name add_global_p
#'
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "broom", "car"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "broom", "car"))
#' # Example 1 ----------------------------------
#' lm(marker ~ age + grade, trial) |>
#' tbl_regression() |>
Expand Down
2 changes: 1 addition & 1 deletion R/add_n.tbl_survfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @param ... Not used
#' @export
#'
#' @examplesIf gtsummary:::is_pkg_installed("survival", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("survival")
#' library(survival)
#' fit1 <- survfit(Surv(ttdeath, death) ~ 1, trial)
#' fit2 <- survfit(Surv(ttdeath, death) ~ trt, trial)
Expand Down
2 changes: 1 addition & 1 deletion R/add_nevent.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @inheritParams add_n_regression
#' @name add_nevent_regression
#'
#' @examplesIf gtsummary:::is_pkg_installed("broom.helpers", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("broom.helpers")
#' # Example 1 ----------------------------------
#' trial |>
#' select(response, trt, grade) |>
Expand Down
4 changes: 2 additions & 2 deletions R/add_nevent.tbl_survfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @param ... Not used
#' @export
#' @family tbl_survfit tools
#' @examplesIf gtsummary:::is_pkg_installed(c("survival", "broom"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("survival", "broom"))
#' library(survival)
#' fit1 <- survfit(Surv(ttdeath, death) ~ 1, trial)
#' fit2 <- survfit(Surv(ttdeath, death) ~ trt, trial)
Expand All @@ -21,7 +21,7 @@ add_nevent.tbl_survfit <- function(x, ...) {
set_cli_abort_call()
check_dots_empty()
updated_call_list <- c(x$call_list, list(add_nevent = match.call()))
check_pkg_installed("broom", reference_pkg = "gtsummary")
check_pkg_installed("broom")

# checking survfit is a standard (not multi-state)
if (some(x$inputs$x, ~ !rlang::is_empty(setdiff(class(.x), c("survfit", "survfit2"))))) {
Expand Down
2 changes: 1 addition & 1 deletion R/add_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ add_p <- function(x, ...) {
#'
#' - `"ancova"` when variable is continuous and `by` variable has two levels.
#'
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed("cardx") && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' # Example 1 ----------------------------------
#' trial |>
#' tbl_summary(by = trt, include = c(age, grade)) |>
Expand Down
2 changes: 1 addition & 1 deletion R/add_p.tbl_continuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @export
#' @return 'tbl_continuous' object
#'
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("cardx")
#' trial |>
#' tbl_continuous(variable = age, by = trt, include = grade) |>
#' add_p()
Expand Down
2 changes: 1 addition & 1 deletion R/add_p.tbl_survfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' If you utilize the `tbl_survfit.data.frame()` S3 method, this is handled for you.
#'
#' @export
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survival", "broom"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survival", "broom"))
#' library(survival)
#'
#' gts_survfit <-
Expand Down
4 changes: 2 additions & 2 deletions R/add_p.tbl_svysummary.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#' @return a gtsummary table of class `"tbl_svysummary"`
#' @export
#'
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survey"), reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "survey")) && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' # Example 1 ----------------------------------
#' # A simple weighted dataset
#' survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) |>
Expand Down Expand Up @@ -48,7 +48,7 @@ add_p.tbl_svysummary <- function(x,
test.args = NULL,
...) {
set_cli_abort_call()
check_pkg_installed("survey", reference_pkg = "gtsummary")
check_pkg_installed("survey")

# check/process inputs -------------------------------------------------------
check_dots_empty()
Expand Down
2 changes: 1 addition & 1 deletion R/add_q.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#'
#' @author Daniel D. Sjoberg, Esther Drill
#' @export
#' @examplesIf gtsummary:::is_pkg_installed("cardx", reference_pkg = "gtsummary") && gtsummary:::is_pkg_installed("broom", reference_pkg = "cardx")
#' @examplesIf gtsummary:::is_pkg_installed("cardx") && gtsummary:::is_pkg_installed("broom", ref = "cardx")
#' # Example 1 ----------------------------------
#' add_q_ex1 <-
#' trial |>
Expand Down
2 changes: 1 addition & 1 deletion R/add_significance_stars.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' @export
#' @return a 'gtsummary' table
#'
#' @examplesIf gtsummary:::is_pkg_installed("car", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("car")
#' tbl <-
#' lm(time ~ ph.ecog + sex, survival::lung) |>
#' tbl_regression(label = list(ph.ecog = "ECOG Score", sex = "Sex"))
Expand Down
4 changes: 2 additions & 2 deletions R/add_vif.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @seealso Review [list, formula, and selector syntax][syntax] used throughout gtsummary
#' @export
#'
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "car"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "car"))
#' # Example 1 ----------------------------------
#' lm(age ~ grade + marker, trial) |>
#' tbl_regression() |>
Expand All @@ -23,7 +23,7 @@
#' add_vif(c("aGVIF", "df"))
add_vif <- function(x, statistic = NULL, estimate_fun = label_style_sigfig(digits = 2)) {
set_cli_abort_call()
check_pkg_installed(c("car", "cardx"), reference_pkg = "gtsummary")
check_pkg_installed(c("car", "cardx"))

# check inputs ---------------------------------------------------------------
check_not_missing(x)
Expand Down
4 changes: 2 additions & 2 deletions R/as_flex_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
#' @return A 'flextable' object
#'
#' @author Daniel D. Sjoberg
#' @examplesIf gtsummary:::is_pkg_installed("flextable", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("flextable")
#' trial |>
#' select(trt, age, grade) |>
#' tbl_summary(by = trt) |>
#' add_p() |>
#' as_flex_table()
as_flex_table <- function(x, include = everything(), return_calls = FALSE, ...) {
set_cli_abort_call()
check_pkg_installed("flextable", reference_pkg = "gtsummary")
check_pkg_installed("flextable")

# deprecated arguments -------------------------------------------------------
dots <- rlang::dots_list(...)
Expand Down
6 changes: 3 additions & 3 deletions R/as_hux_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @return A \{huxtable\} object
#'
#' @author David Hugh-Jones, Daniel D. Sjoberg
#' @examplesIf gtsummary:::is_pkg_installed("huxtable", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("huxtable")
#' trial |>
#' tbl_summary(by = trt, include = c(age, grade)) |>
#' add_p() |>
Expand All @@ -33,7 +33,7 @@ as_hux_table <- function(x, include = everything(), return_calls = FALSE,
strip_md_bold = FALSE) {
set_cli_abort_call()
check_class(x, "gtsummary")
check_pkg_installed("huxtable", reference_pkg = "gtsummary")
check_pkg_installed("huxtable")
check_scalar_logical(return_calls)

if (!isFALSE(strip_md_bold)) {
Expand Down Expand Up @@ -86,7 +86,7 @@ as_hux_table <- function(x, include = everything(), return_calls = FALSE,
as_hux_xlsx <- function(x, file, include = everything(), bold_header_rows = TRUE) {
set_cli_abort_call()
check_class(x, "gtsummary")
check_pkg_installed(c("huxtable", "openxlsx"), reference_pkg = "gtsummary")
check_pkg_installed(c("huxtable", "openxlsx"))
check_scalar_logical(bold_header_rows)

# save list of expressions to run --------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions R/as_kable_extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#' @return A \{kableExtra\} table
#'
#' @author Daniel D. Sjoberg
#' @examplesIf gtsummary:::is_pkg_installed("kableExtra", reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed("kableExtra")
#' # basic gtsummary tbl to build upon
#' as_kable_extra_base <-
#' trial |>
Expand Down Expand Up @@ -89,7 +89,7 @@ as_kable_extra <- function(x,
addtl_fmt = TRUE,
return_calls = FALSE) {
set_cli_abort_call()
check_pkg_installed(c("kableExtra", "knitr"), reference_pkg = "gtsummary")
check_pkg_installed(c("kableExtra", "knitr"))

# process inputs -------------------------------------------------------------
check_class(x, "gtsummary")
Expand Down
2 changes: 1 addition & 1 deletion R/combine_terms.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
combine_terms <- function(x, formula_update, label = NULL, quiet, ...) {
set_cli_abort_call()
updated_call_list <- c(x$call_list, list(combine_terms = match.call()))
check_pkg_installed("cardx", reference_pkg = "gtsummary")
check_pkg_installed("cardx")

# deprecation ----------------------------------------------------------------
if (!missing(quiet)) {
Expand Down
12 changes: 6 additions & 6 deletions R/custom_tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#' @name custom_tidiers
#' @rdname custom_tidiers
#' @export
#' @examplesIf gtsummary:::is_pkg_installed(c("effectsize", "mice", "parameters"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("effectsize", "mice", "parameters"))
#' # Example 1 ----------------------------------
#' mod <- lm(age ~ marker + grade, trial)
#'
Expand Down Expand Up @@ -92,7 +92,7 @@ tidy_standardize <- function(x,
...,
quiet = FALSE) {
set_cli_abort_call()
check_pkg_installed(c("parameters", "effectsize"), reference_pkg = "gtsummary")
check_pkg_installed(c("parameters", "effectsize"))
check_scalar_logical(exponentiate)
check_scalar_logical(conf.int)
check_scalar_range(conf.level, range = c(0, 1))
Expand Down Expand Up @@ -136,7 +136,7 @@ tidy_bootstrap <- function(x,
...,
quiet = FALSE) {
set_cli_abort_call()
check_pkg_installed("parameters", reference_pkg = "gtsummary")
check_pkg_installed("parameters")
check_scalar_logical(exponentiate)
check_scalar_logical(conf.int)
check_scalar_range(conf.level, range = c(0, 1))
Expand Down Expand Up @@ -182,7 +182,7 @@ tidy_robust <- function(x,
...,
quiet = FALSE) {
set_cli_abort_call()
check_pkg_installed(c("parameters", "insight"), reference_pkg = "gtsummary")
check_pkg_installed(c("parameters", "insight"))
check_scalar_logical(exponentiate)
check_scalar_logical(conf.int)
check_scalar_range(conf.level, range = c(0, 1))
Expand Down Expand Up @@ -238,7 +238,7 @@ tidy_robust <- function(x,
#' @export
pool_and_tidy_mice <- function(x, pool.args = NULL, ..., quiet = FALSE) {
set_cli_abort_call()
check_pkg_installed("mice", reference_pkg = "gtsummary")
check_pkg_installed("mice")

if (!missing(quiet)) {
lifecycle::deprecate_stop(
Expand Down Expand Up @@ -285,7 +285,7 @@ tidy_gam <- function(x, conf.int = FALSE, exponentiate = FALSE, conf.level = 0.9
#' @export
tidy_wald_test <- function(x, tidy_fun = NULL, ...) {
set_cli_abort_call()
check_pkg_installed(c("aod", "broom.helpers"), reference_pkg = "gtsummary")
check_pkg_installed(c("aod", "broom.helpers"))

tidy_fun <- tidy_fun %||% broom.helpers::tidy_with_broom_or_parameters

Expand Down
4 changes: 2 additions & 2 deletions R/gather_ard.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @return list
#' @export
#'
#' @examplesIf gtsummary:::is_pkg_installed('cardx', reference_pkg = 'gtsummary')
#' @examplesIf gtsummary:::is_pkg_installed('cardx')
#' tbl_summary(trial, by = trt, include = age) |>
#' add_overall() |>
#' add_p() |>
Expand All @@ -28,7 +28,7 @@ gather_ard <- function(x) {

# the ARD for regression models is an additional calculation, so we don't do it by default
if (inherits(x, "tbl_regression")) {
check_pkg_installed("cardx", reference_pkg = "gtsummary")
check_pkg_installed("cardx")
return(cardx::ard_regression(x$inputs$x))
}

Expand Down
4 changes: 2 additions & 2 deletions R/glance_fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ glance_fun_s3 <- function(x, ...) {
#' @name glance_fun_s3
#' @export
glance_fun_s3.default <- function(x, ...) {
check_pkg_installed("broom", reference_pkg = "gtsummary")
check_pkg_installed("broom")
check_dots_empty()
broom::glance
}

#' @name glance_fun_s3
#' @export
glance_fun_s3.mira <- function(x, ...) {
check_pkg_installed(c("broom", "mice"), reference_pkg = "gtsummary")
check_pkg_installed(c("broom", "mice"))
check_dots_empty()
\(x) broom::glance(mice::pool(x))
}
6 changes: 3 additions & 3 deletions R/global_pvalue_fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @return data frame
#' @keywords internal
#'
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "broom", "car"), reference_pkg = "gtsummary")
#' @examplesIf gtsummary:::is_pkg_installed(c("cardx", "broom", "car"))
#' lm(age ~ stage + grade, trial) |>
#' global_pvalue_fun(type = "III")
NULL
Expand All @@ -28,15 +28,15 @@ global_pvalue_fun <- function(x, type, ...) {
#' @rdname global_pvalue_fun
#' @export
global_pvalue_fun.default <- function(x, type, ...) {
check_pkg_installed(c("cardx"), reference_pkg = "gtsummary")
check_pkg_installed(c("cardx"))

cardx::ard_car_anova(x, type = type, ...)
}

#' @rdname global_pvalue_fun
#' @export
global_pvalue_fun.geeglm <- function(x, type, ...) {
check_pkg_installed(c("cardx"), reference_pkg = "gtsummary")
check_pkg_installed(c("cardx"))

cardx::ard_aod_wald_test(x, ...)
}
Loading

0 comments on commit 901cc30

Please sign in to comment.