From 5456c3026ac4f1b0d2438c27914b2ca09664e47e Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Fri, 3 May 2024 23:25:00 +0000 Subject: [PATCH 01/24] [skip actions] Bump version to 0.1.0.9034 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d2b054b99..893b81536 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9033 +Version: 0.1.0.9034 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index f600304b6..453b6cedc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9033 +# cardx 0.1.0.9034 ### Breaking Changes From ec0ae0cbd4ec742c7ce2c2ab4202d8d819f56587 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Sat, 4 May 2024 15:10:33 -0700 Subject: [PATCH 02/24] adding CIs to SMDs (#143) **What changes are proposed in this pull request?** * Style this entry in a way that can be copied directly into `NEWS.md`. (#, @) Provide more detail here as needed. **Reference GitHub issue associated with pull request.** _e.g., 'closes #'_ -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_smd_smd.R | 40 ++++++++++++++++++++----- R/import-standalone-checks.R | 23 +++++++++++++- inst/WORDLIST | 1 + man/ard_smd_smd.Rd | 17 +++++++---- tests/testthat/_snaps/ard_regression.md | 18 +++++++++++ tests/testthat/test-ard_smd_smd.R | 6 ++-- 6 files changed, 88 insertions(+), 17 deletions(-) diff --git a/R/ard_smd_smd.R b/R/ard_smd_smd.R index 7bcd80c85..b9024e06f 100644 --- a/R/ard_smd_smd.R +++ b/R/ard_smd_smd.R @@ -2,6 +2,8 @@ #' #' @description #' Standardized mean difference calculated via [`smd::smd()`] with `na.rm = TRUE`. +#' Additionally, this function add a confidence interval to the SMD when +#' `std.error=TRUE`, which the original `smd::smd()` does not include. #' #' @param data (`data.frame`/`survey.design`)\cr #' a data frame or object of class 'survey.design' @@ -11,15 +13,20 @@ #' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr #' column names to be compared. Independent tests will be computed for #' each variable. +#' @param conf.level (scalar `numeric`)\cr +#' confidence level for confidence interval. Default is `0.95`. +#' @param std.error (scalar `logical`)\cr +#' Logical indicator for computing standard errors using `smd::compute_smd_var()`. +#' Default is `TRUE`. #' @inheritDotParams smd::smd -x -g -w -na.rm #' #' @return ARD data frame #' @export #' #' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "smd", reference_pkg = "cardx")) -#' ard_smd_smd(cards::ADSL, by = ARM, variables = AGE, std.error = TRUE) -#' ard_smd_smd(cards::ADSL, by = ARM, variables = AGEGR1, std.error = TRUE) -ard_smd_smd <- function(data, by, variables, ...) { +#' ard_smd_smd(cards::ADSL, by = SEX, variables = AGE) +#' ard_smd_smd(cards::ADSL, by = SEX, variables = AGEGR1) +ard_smd_smd <- function(data, by, variables, std.error = TRUE, conf.level = 0.95, ...) { set_cli_abort_call() # check installed packages --------------------------------------------------- @@ -37,11 +44,14 @@ ard_smd_smd <- function(data, by, variables, ...) { data <- design$variables } + # continue check/process inputs ---------------------------------------------- check_data_frame(data) data <- dplyr::ungroup(data) cards::process_selectors(data, by = {{ by }}, variables = {{ variables }}) check_scalar(by) + # This check can be relaxed, but would require some changes to handle multi-row outputs + check_n_levels(data[[by]], 2L, message = "The {.arg by} column must have {.val {length}} levels.") # if no variables selected, return empty tibble ------------------------------ if (is_empty(variables)) { @@ -58,10 +68,24 @@ ard_smd_smd <- function(data, by, variables, ...) { lst_tidy = cards::eval_capture_conditions( switch(as.character(is_survey), - "TRUE" = smd::smd(x = data[[variable]], g = data[[by]], w = stats::weights(design), na.rm = TRUE, ...), - "FALSE" = smd::smd(x = data[[variable]], g = data[[by]], na.rm = TRUE, ...) + "TRUE" = smd::smd(x = data[[variable]], g = data[[by]], w = stats::weights(design), na.rm = TRUE, std.error = std.error, ...), + "FALSE" = smd::smd(x = data[[variable]], g = data[[by]], na.rm = TRUE, std.error = std.error, ...) ) |> - dplyr::select(-any_of("term")) + dplyr::select(-any_of("term")) %>% + # styler: off + {if (isTRUE(std.error)) + dplyr::mutate( + ., + conf.low = .data$estimate + stats::qnorm((1 - .env$conf.level) / 2) * .data$std.error, + conf.high = .data$estimate - stats::qnorm((1 - .env$conf.level) / 2) * .data$std.error, + method = "Standardized Mean Difference" + ) + else + dplyr::mutate( + ., + method = "Standardized Mean Difference" + )} + # styler: on ), ... ) @@ -77,8 +101,8 @@ ard_smd_smd <- function(data, by, variables, ...) { cards::tidy_as_ard( lst_tidy = lst_tidy, tidy_result_names = c("estimate", "std.error"), - fun_args_to_record = "gref", - formals = formals(smd::smd)["gref"], + fun_args_to_record = c("gref"), + formals = formals(smd::smd)[c("gref")], # removing the `std.error` ARGUMENT (not the result) passed_args = dots_list(...) |> utils::modifyList(list(std.error = NULL)), lst_ard_columns = list(group1 = by, variable = variable, context = "smd_smd") diff --git a/R/import-standalone-checks.R b/R/import-standalone-checks.R index 5d1379822..88c255e3a 100644 --- a/R/import-standalone-checks.R +++ b/R/import-standalone-checks.R @@ -5,7 +5,7 @@ # --- # repo: ddsjoberg/standalone # file: standalone-checks.R -# last-updated: 2024-04-10 +# last-updated: 2024-05-04 # license: https://unlicense.org # dependencies: standalone-cli_call_env.R # imports: [rlang, cli] @@ -244,6 +244,27 @@ check_scalar <- function(x, ) } +#' Check Number of Levels +#' +#' @param n_levels Number of required levels (after NA are removed). +#' @inheritParams check_class +#' @keywords internal +#' @noRd +check_n_levels <- function(x, + n_levels, + message = + "The {.arg {arg_name}} argument must have {.val {length}} levels.", + arg_name = rlang::caller_arg(x), + class = "check_n_levels", + call = get_cli_abort_call()) { + check_length( + x = stats::na.omit(x) |> unique(), + length = n_levels, message = message, + allow_empty = FALSE, arg_name = arg_name, + class = class, call = call + ) +} + #' Check Range #' #' @param x numeric scalar to check diff --git a/inst/WORDLIST b/inst/WORDLIST index cb6fc6490..f35e0a160 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -13,6 +13,7 @@ McNemar's Newcombe Rao Rua +SMD Su VIF XG diff --git a/man/ard_smd_smd.Rd b/man/ard_smd_smd.Rd index 27ffee4e4..206a7397f 100644 --- a/man/ard_smd_smd.Rd +++ b/man/ard_smd_smd.Rd @@ -4,7 +4,7 @@ \alias{ard_smd_smd} \title{ARD Standardized Mean Difference} \usage{ -ard_smd_smd(data, by, variables, ...) +ard_smd_smd(data, by, variables, std.error = TRUE, conf.level = 0.95, ...) } \arguments{ \item{data}{(\code{data.frame}/\code{survey.design})\cr @@ -18,11 +18,16 @@ column name to compare by.} column names to be compared. Independent tests will be computed for each variable.} +\item{std.error}{(scalar \code{logical})\cr +Logical indicator for computing standard errors using \code{smd::compute_smd_var()}. +Default is \code{TRUE}.} + +\item{conf.level}{(scalar \code{numeric})\cr +confidence level for confidence interval. Default is \code{0.95}.} + \item{...}{ Arguments passed on to \code{\link[smd:smd]{smd::smd}} \describe{ - \item{\code{std.error}}{Logical indicator for computing standard errors using -\code{\link[smd]{compute_smd_var}}. Defaults to \code{FALSE}.} \item{\code{gref}}{an integer indicating which level of \code{g} to use as the reference group. Defaults to \code{1}.} }} @@ -32,10 +37,12 @@ ARD data frame } \description{ Standardized mean difference calculated via \code{\link[smd:smd]{smd::smd()}} with \code{na.rm = TRUE}. +Additionally, this function add a confidence interval to the SMD when +\code{std.error=TRUE}, which the original \code{smd::smd()} does not include. } \examples{ \dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "smd", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} -ard_smd_smd(cards::ADSL, by = ARM, variables = AGE, std.error = TRUE) -ard_smd_smd(cards::ADSL, by = ARM, variables = AGEGR1, std.error = TRUE) +ard_smd_smd(cards::ADSL, by = SEX, variables = AGE) +ard_smd_smd(cards::ADSL, by = SEX, variables = AGEGR1) \dontshow{\}) # examplesIf} } diff --git a/tests/testthat/_snaps/ard_regression.md b/tests/testthat/_snaps/ard_regression.md index c3056702f..5d9524bd2 100644 --- a/tests/testthat/_snaps/ard_regression.md +++ b/tests/testthat/_snaps/ard_regression.md @@ -50,3 +50,21 @@ 42 ARM Xanomeline Low Dose conf.low -2.039 43 ARM Xanomeline Low Dose conf.high 2.953 +# ard_regression() works specifying custom tidier + + Code + dplyr::mutate(dplyr::filter(dplyr::select(as.data.frame(ard_regression(lme4::lmer( + mpg ~ hp + (1 | cyl), data = mtcars), tidy_fun = broom.mixed::tidy)), + -context, -stat_label, -fmt_fn), map_lgl(stat, is.numeric)), stat = lapply(stat, + function(x) ifelse(is.numeric(x), cards::round5(x, 3), x))) + Output + variable variable_level stat_name stat + 1 hp n_obs 32 + 2 hp estimate -0.03 + 3 hp std.error 0.015 + 4 hp statistic -2.088 + 5 hp conf.low -0.059 + 6 hp conf.high -0.002 + 7 cyl.sd__(Intercept) cyl.sd__(Intercept) estimate 4.023 + 8 Residual.sd__Observation Residual.sd__Observation estimate 3.149 + diff --git a/tests/testthat/test-ard_smd_smd.R b/tests/testthat/test-ard_smd_smd.R index 02a2d4523..0744527ea 100644 --- a/tests/testthat/test-ard_smd_smd.R +++ b/tests/testthat/test-ard_smd_smd.R @@ -52,11 +52,11 @@ test_that("ard_smd() works with survey data", { ) }) -test_that("ard_proptest() error messaging", { +test_that("ard_smd_smd() error messaging", { # mis-specify the gref argument expect_error( bad_gref <- - ard_smd_smd(cards::ADSL, by = ARM, variables = AGE, std.error = TRUE, gref = 0) |> + ard_smd_smd(cards::ADSL, by = SEX, variables = AGE, std.error = TRUE, gref = 0) |> as.data.frame(), NA ) @@ -66,6 +66,6 @@ test_that("ard_proptest() error messaging", { # check the error message it the one we expect expect_equal( bad_gref$error |> unique() |> cli::ansi_strip(), - "gref must be an integer within 3" + "gref must be an integer within 2" ) }) From 1a4e5c188a8639bf8f847e4144b6723b2483928a Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Sat, 4 May 2024 22:11:29 +0000 Subject: [PATCH 03/24] [skip actions] Bump version to 0.1.0.9035 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 893b81536..2fed0bc67 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9034 +Version: 0.1.0.9035 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 453b6cedc..95aa6af5c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9034 +# cardx 0.1.0.9035 ### Breaking Changes From 239bf36e8414d94240161918916eb00610844952 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Sun, 5 May 2024 19:10:56 -0700 Subject: [PATCH 04/24] Adding method to effectsize pkg ard functions (#144) **What changes are proposed in this pull request?** * Style this entry in a way that can be copied directly into `NEWS.md`. (#, @) Provide more detail here as needed. **Reference GitHub issue associated with pull request.** _e.g., 'closes #'_ -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_effectsize_cohens_d.R | 6 ++++-- R/ard_effectsize_hedges_g.R | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/ard_effectsize_cohens_d.R b/R/ard_effectsize_cohens_d.R index 91f5441a1..1babbd898 100644 --- a/R/ard_effectsize_cohens_d.R +++ b/R/ard_effectsize_cohens_d.R @@ -78,7 +78,8 @@ ard_effectsize_cohens_d <- function(data, by, variables, conf.level = 0.95, ...) lst_tidy = cards::eval_capture_conditions( effectsize::cohens_d(data[[variable]] ~ data[[by]], data = data, paired = FALSE, ci = conf.level, ...) |> - parameters::standardize_names(style = "broom") + parameters::standardize_names(style = "broom") |> + dplyr::mutate(method = "Cohen's D") ), paired = FALSE, ... @@ -127,7 +128,8 @@ ard_effectsize_paired_cohens_d <- function(data, by, variables, id, conf.level = data_wide <- .paired_data_pivot_wider(data, by = by, variable = variable, id = id) # perform paired cohen's d test effectsize::cohens_d(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) |> - parameters::standardize_names(style = "broom") + parameters::standardize_names(style = "broom") |> + dplyr::mutate(method = "Paired Cohen's D") }), paired = TRUE, ... diff --git a/R/ard_effectsize_hedges_g.R b/R/ard_effectsize_hedges_g.R index 58b228b5d..d130b7b4f 100644 --- a/R/ard_effectsize_hedges_g.R +++ b/R/ard_effectsize_hedges_g.R @@ -84,7 +84,8 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...) package = "effectsize", code = hedges_g(data[[variable]] ~ data[[by]], paired = FALSE, ci = conf.level, ...) ) |> - parameters::standardize_names(style = "broom") + parameters::standardize_names(style = "broom") |> + dplyr::mutate(method = "Hedge's G") ), paired = FALSE, ... @@ -135,7 +136,8 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, conf.level = package = "effectsize", code = hedges_g(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) ) |> - parameters::standardize_names(style = "broom") + parameters::standardize_names(style = "broom") |> + dplyr::mutate(method = "Paired Hedge's G") }), paired = TRUE, ... From 5ffd9d653bd070baf8c0f96e7424809cea7491ec Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 6 May 2024 02:11:50 +0000 Subject: [PATCH 05/24] [skip actions] Bump version to 0.1.0.9036 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2fed0bc67..1e3b9602c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9035 +Version: 0.1.0.9036 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 95aa6af5c..e4ebe44f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9035 +# cardx 0.1.0.9036 ### Breaking Changes From aff6b34b5b46665c2455e1e9a4375e496e972d3e Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Sun, 5 May 2024 21:22:34 -0700 Subject: [PATCH 06/24] =?UTF-8?q?removing=20missing=20values=20before=20ca?= =?UTF-8?q?lculating=20values=20to=20avoid=20note=20about=E2=80=A6=20(#145?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … NA values being dropped **What changes are proposed in this pull request?** * Style this entry in a way that can be copied directly into `NEWS.md`. (#, @) Provide more detail here as needed. **Reference GitHub issue associated with pull request.** _e.g., 'closes #'_ -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_effectsize_cohens_d.R | 13 +++++++++++-- R/ard_effectsize_hedges_g.R | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/R/ard_effectsize_cohens_d.R b/R/ard_effectsize_cohens_d.R index 1babbd898..b6e9d29a7 100644 --- a/R/ard_effectsize_cohens_d.R +++ b/R/ard_effectsize_cohens_d.R @@ -77,7 +77,13 @@ ard_effectsize_cohens_d <- function(data, by, variables, conf.level = 0.95, ...) variable = variable, lst_tidy = cards::eval_capture_conditions( - effectsize::cohens_d(data[[variable]] ~ data[[by]], data = data, paired = FALSE, ci = conf.level, ...) |> + effectsize::cohens_d( + reformulate2(by, response = variable), + data = data |> tidyr::drop_na(all_of(c(by, variable))), + paired = FALSE, + ci = conf.level, + ... + ) |> parameters::standardize_names(style = "broom") |> dplyr::mutate(method = "Cohen's D") ), @@ -125,7 +131,10 @@ ard_effectsize_paired_cohens_d <- function(data, by, variables, id, conf.level = lst_tidy = cards::eval_capture_conditions({ # adding this reshape inside the eval, so if there is an error it's captured in the ARD object - data_wide <- .paired_data_pivot_wider(data, by = by, variable = variable, id = id) + data_wide <- + data |> + tidyr::drop_na(all_of(c(id, by, variable))) |> + .paired_data_pivot_wider(by = by, variable = variable, id = id) # perform paired cohen's d test effectsize::cohens_d(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) |> parameters::standardize_names(style = "broom") |> diff --git a/R/ard_effectsize_hedges_g.R b/R/ard_effectsize_hedges_g.R index d130b7b4f..f129a5186 100644 --- a/R/ard_effectsize_hedges_g.R +++ b/R/ard_effectsize_hedges_g.R @@ -82,7 +82,14 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...) # Will also need to remove `hedges_g` from globalVariables() withr::with_namespace( package = "effectsize", - code = hedges_g(data[[variable]] ~ data[[by]], paired = FALSE, ci = conf.level, ...) + code = + hedges_g( + reformulate2(by, response = variable), + data = data |> tidyr::drop_na(all_of(c(by, variable))), + paired = FALSE, + ci = conf.level, + ... + ) ) |> parameters::standardize_names(style = "broom") |> dplyr::mutate(method = "Hedge's G") @@ -130,7 +137,10 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, conf.level = lst_tidy = cards::eval_capture_conditions({ # adding this reshape inside the eval, so if there is an error it's captured in the ARD object - data_wide <- .paired_data_pivot_wider(data, by = by, variable = variable, id = id) + data_wide <- + data |> + tidyr::drop_na(all_of(c(id, by, variable))) |> + .paired_data_pivot_wider(by = by, variable = variable, id = id) # perform paired cohen's d test withr::with_namespace( package = "effectsize", From d2a2e265dce947c66ded83102d072b4a7d99a911 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 6 May 2024 04:23:28 +0000 Subject: [PATCH 07/24] [skip actions] Bump version to 0.1.0.9037 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1e3b9602c..4a6968529 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9036 +Version: 0.1.0.9037 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index e4ebe44f0..e5665481b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9036 +# cardx 0.1.0.9037 ### Breaking Changes From a9faba47a4a317b60c9263d8558530330cfb63e5 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Sun, 5 May 2024 21:31:40 -0700 Subject: [PATCH 08/24] more updates for effectsize --- R/ard_effectsize_cohens_d.R | 3 ++- R/ard_effectsize_hedges_g.R | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/ard_effectsize_cohens_d.R b/R/ard_effectsize_cohens_d.R index b6e9d29a7..e57890d7d 100644 --- a/R/ard_effectsize_cohens_d.R +++ b/R/ard_effectsize_cohens_d.R @@ -134,7 +134,8 @@ ard_effectsize_paired_cohens_d <- function(data, by, variables, id, conf.level = data_wide <- data |> tidyr::drop_na(all_of(c(id, by, variable))) |> - .paired_data_pivot_wider(by = by, variable = variable, id = id) + .paired_data_pivot_wider(by = by, variable = variable, id = id) |> + tidyr::drop_na(any_of(c("by1", "by2"))) # perform paired cohen's d test effectsize::cohens_d(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) |> parameters::standardize_names(style = "broom") |> diff --git a/R/ard_effectsize_hedges_g.R b/R/ard_effectsize_hedges_g.R index f129a5186..7cd99263d 100644 --- a/R/ard_effectsize_hedges_g.R +++ b/R/ard_effectsize_hedges_g.R @@ -140,7 +140,8 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, conf.level = data_wide <- data |> tidyr::drop_na(all_of(c(id, by, variable))) |> - .paired_data_pivot_wider(by = by, variable = variable, id = id) + .paired_data_pivot_wider(by = by, variable = variable, id = id) |> + tidyr::drop_na(any_of(c("by1", "by2"))) # perform paired cohen's d test withr::with_namespace( package = "effectsize", From 24dd32eadb8c378f6570880051b95afc28c3c82d Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 6 May 2024 04:32:32 +0000 Subject: [PATCH 09/24] [skip actions] Bump version to 0.1.0.9038 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4a6968529..6933c944c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9037 +Version: 0.1.0.9038 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index e5665481b..3ebf949ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9037 +# cardx 0.1.0.9038 ### Breaking Changes From 1a9c7ee9ac6fa179d836b1fc3d68f10520ce5c7c Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Mon, 6 May 2024 11:54:52 -0700 Subject: [PATCH 10/24] Patch for `construct_model()` (#147) **Reference GitHub issue associated with pull request.** _e.g., 'closes #'_ Related #146 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/construction_helpers.R | 6 +++++- tests/testthat/test-ard_stats_anova.R | 4 ++-- tests/testthat/test-construction_helpers.R | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/R/construction_helpers.R b/R/construction_helpers.R index 47e220cc2..52b867052 100644 --- a/R/construction_helpers.R +++ b/R/construction_helpers.R @@ -117,7 +117,11 @@ construct_model.survey.design <- function(x, formula, method, method.args = list } .as_list_of_exprs <- function(x) { - call_args(enexpr(x)) + x_enexpr <- enexpr(x) + if (tryCatch(inherits(x, "list"), error = \(x) FALSE)) { + return(x) + } + call_args(x_enexpr) } #' @rdname construction_helpers diff --git a/tests/testthat/test-ard_stats_anova.R b/tests/testthat/test-ard_stats_anova.R index db55f67d9..1131cfbea 100644 --- a/tests/testthat/test-ard_stats_anova.R +++ b/tests/testthat/test-ard_stats_anova.R @@ -125,8 +125,8 @@ test_that("ard_stats_anova.data.frame() works", { } ard_anova_geeglm2 <- args_fun(list(id = cyl)) expect_equal( - ard_anova_geeglm2, - ard_anova_geeglm + ard_anova_geeglm2$stat, + ard_anova_geeglm$stat ) }) diff --git a/tests/testthat/test-construction_helpers.R b/tests/testthat/test-construction_helpers.R index 0ff715752..8efbdb0bf 100644 --- a/tests/testthat/test-construction_helpers.R +++ b/tests/testthat/test-construction_helpers.R @@ -30,6 +30,25 @@ test_that("construct_model() works", { "cannot be namespaced" ) + expect_equal( + { + outside_fun <- function() { + method.args <- list() + + construct_model.data.frame( + mtcars, + formula = mpg ~ cyl, + method = "lm", + method.args = method.args + ) |> + coef() + } + + outside_fun() + }, + lm(mpg ~ cyl, mtcars) |> coef() + ) + # now the survey method ------- # styler: off expect_equal({ From f74cdb62a67a04829a5f6a5846084adaaa34719e Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 6 May 2024 18:55:47 +0000 Subject: [PATCH 11/24] [skip actions] Bump version to 0.1.0.9039 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6933c944c..10072d476 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9038 +Version: 0.1.0.9039 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 3ebf949ff..798ef9b99 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9038 +# cardx 0.1.0.9039 ### Breaking Changes From 0e54be32825589d942754f51d3f22bd5411ec557 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Mon, 13 May 2024 08:46:38 -0700 Subject: [PATCH 12/24] Add pkg installation checks for car::Anova() and stats::aov() ARD functions (#149) **What changes are proposed in this pull request?** The `ard_stats_aov()` and `ard_car_anova()` functions didn't have checks for the installation of the {parameters} package for the examples and test files. They have now been added. -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [ ] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_car_anova.R | 4 ++-- R/ard_smd_smd.R | 2 +- R/ard_stats_aov.R | 4 ++-- man/ard_car_anova.Rd | 2 +- man/ard_smd_smd.Rd | 7 +------ man/ard_stats_aov.Rd | 2 +- tests/testthat/test-ard_car_anova.R | 2 +- tests/testthat/test-ard_stats_aov.R | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/R/ard_car_anova.R b/R/ard_car_anova.R index 2b4f91270..0e112d04f 100644 --- a/R/ard_car_anova.R +++ b/R/ard_car_anova.R @@ -8,7 +8,7 @@ #' @return data frame #' @export #' -#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "car"), reference_pkg = "cardx")) +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "car", "parameters"), reference_pkg = "cardx")) #' lm(AGE ~ ARM, data = cards::ADSL) |> #' ard_car_anova() #' @@ -18,7 +18,7 @@ ard_car_anova <- function(x, ...) { set_cli_abort_call() # check installed packages --------------------------------------------------- - check_pkg_installed(pkg = c("broom.helpers", "car"), reference_pkg = "cardx") + check_pkg_installed(pkg = c("broom.helpers", "car", "parameters"), reference_pkg = "cardx") # check inputs --------------------------------------------------------------- check_not_missing(x) diff --git a/R/ard_smd_smd.R b/R/ard_smd_smd.R index b9024e06f..b7ed54650 100644 --- a/R/ard_smd_smd.R +++ b/R/ard_smd_smd.R @@ -18,7 +18,7 @@ #' @param std.error (scalar `logical`)\cr #' Logical indicator for computing standard errors using `smd::compute_smd_var()`. #' Default is `TRUE`. -#' @inheritDotParams smd::smd -x -g -w -na.rm +#' @param ... arguments passed to `smd::smd()` #' #' @return ARD data frame #' @export diff --git a/R/ard_stats_aov.R b/R/ard_stats_aov.R index 81849ba42..32bf29175 100644 --- a/R/ard_stats_aov.R +++ b/R/ard_stats_aov.R @@ -10,13 +10,13 @@ #' @return ARD data frame #' @export #' -#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom.helpers", reference_pkg = "cardx")) +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "parameters"), reference_pkg = "cardx")) #' ard_stats_aov(AGE ~ ARM, data = cards::ADSL) ard_stats_aov <- function(formula, data, ...) { set_cli_abort_call() # check installed packages --------------------------------------------------- - check_pkg_installed(c("broom.helpers"), reference_pkg = "cardx") + check_pkg_installed(c("broom.helpers", "parameters"), reference_pkg = "cardx") # check/process inputs ------------------------------------------------------- check_not_missing(formula) diff --git a/man/ard_car_anova.Rd b/man/ard_car_anova.Rd index 3b300f4ad..a7fa67f51 100644 --- a/man/ard_car_anova.Rd +++ b/man/ard_car_anova.Rd @@ -18,7 +18,7 @@ data frame Function takes a regression model object and calculated ANOVA using \code{\link[car:Anova]{car::Anova()}}. } \examples{ -\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "car"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "car", "parameters"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} lm(AGE ~ ARM, data = cards::ADSL) |> ard_car_anova() diff --git a/man/ard_smd_smd.Rd b/man/ard_smd_smd.Rd index 206a7397f..f4e9e060e 100644 --- a/man/ard_smd_smd.Rd +++ b/man/ard_smd_smd.Rd @@ -25,12 +25,7 @@ Default is \code{TRUE}.} \item{conf.level}{(scalar \code{numeric})\cr confidence level for confidence interval. Default is \code{0.95}.} -\item{...}{ - Arguments passed on to \code{\link[smd:smd]{smd::smd}} - \describe{ - \item{\code{gref}}{an integer indicating which level of \code{g} to use as the reference -group. Defaults to \code{1}.} - }} +\item{...}{arguments passed to \code{smd::smd()}} } \value{ ARD data frame diff --git a/man/ard_stats_aov.Rd b/man/ard_stats_aov.Rd index c38d1a37e..40e29c361 100644 --- a/man/ard_stats_aov.Rd +++ b/man/ard_stats_aov.Rd @@ -23,7 +23,7 @@ Analysis results data for Analysis of Variance. Calculated with \code{stats::aov()} } \examples{ -\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom.helpers", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "parameters"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} ard_stats_aov(AGE ~ ARM, data = cards::ADSL) \dontshow{\}) # examplesIf} } diff --git a/tests/testthat/test-ard_car_anova.R b/tests/testthat/test-ard_car_anova.R index 5468f15fb..d1d45b629 100644 --- a/tests/testthat/test-ard_car_anova.R +++ b/tests/testthat/test-ard_car_anova.R @@ -1,5 +1,5 @@ skip_if_not( - do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("broom.helpers", "car"), reference_pkg = "cardx")) + is_pkg_installed(c("broom.helpers", "car", "parameters"), reference_pkg = "cardx") ) test_that("ard_car_anova() works", { diff --git a/tests/testthat/test-ard_stats_aov.R b/tests/testthat/test-ard_stats_aov.R index 01de036ce..ad56ee6ba 100644 --- a/tests/testthat/test-ard_stats_aov.R +++ b/tests/testthat/test-ard_stats_aov.R @@ -1,4 +1,4 @@ -skip_if_not(is_pkg_installed("broom.helpers", reference_pkg = "cardx")) +skip_if_not(is_pkg_installed(c("broom.helpers", "parameters"), reference_pkg = "cardx")) test_that("ard_aov() works", { expect_error( From 8aa00703b70dcc3acbb877f54f0984fca21674ae Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Mon, 13 May 2024 15:47:34 +0000 Subject: [PATCH 13/24] [skip actions] Bump version to 0.1.0.9040 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 10072d476..cf7ce02f3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9039 +Version: 0.1.0.9040 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 798ef9b99..d77768a5b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9039 +# cardx 0.1.0.9040 ### Breaking Changes From e30945f6917ce58fbe09bbe4a5126295297eaa62 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 15 May 2024 10:39:42 -0700 Subject: [PATCH 14/24] doc update --- R/construction_helpers.R | 3 ++- man/construction_helpers.Rd | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/construction_helpers.R b/R/construction_helpers.R index 52b867052..03b759fe0 100644 --- a/R/construction_helpers.R +++ b/R/construction_helpers.R @@ -47,7 +47,8 @@ #' method = "glmer", #' method.args = list(family = binomial), #' package = "lme4" -#' ) +#' ) |> +#' broom::tidy() #' #' construct_model( #' x = mtcars |> dplyr::rename(`M P G` = mpg), diff --git a/man/construction_helpers.Rd b/man/construction_helpers.Rd index 3264af7f3..436bdd095 100644 --- a/man/construction_helpers.Rd +++ b/man/construction_helpers.Rd @@ -113,7 +113,8 @@ construct_model( method = "glmer", method.args = list(family = binomial), package = "lme4" -) +) |> + broom::tidy() construct_model( x = mtcars |> dplyr::rename(`M P G` = mpg), From 270127b96cd950c87f31eccf41bea8adafa17883 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Wed, 15 May 2024 17:40:41 +0000 Subject: [PATCH 15/24] [skip actions] Bump version to 0.1.0.9041 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cf7ce02f3..244c76133 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9040 +Version: 0.1.0.9041 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index d77768a5b..068dd38a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9040 +# cardx 0.1.0.9041 ### Breaking Changes From 39f589bb276b913897e43e71d5072b47e8483d53 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 15 May 2024 11:19:39 -0700 Subject: [PATCH 16/24] doc update --- R/construction_helpers.R | 4 ++-- man/construction_helpers.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/construction_helpers.R b/R/construction_helpers.R index 03b759fe0..8ceeb1f49 100644 --- a/R/construction_helpers.R +++ b/R/construction_helpers.R @@ -40,7 +40,7 @@ #' @return depends on the calling function #' @name construction_helpers #' -#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("withr", "lme4", "broom.helpers"), reference_pkg = "cardx")) +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("withr", "lme4", "broom.helpers", "broom.mixed"), reference_pkg = "cardx")) #' construct_model( #' x = mtcars, #' formula = am ~ mpg + (1 | vs), @@ -48,7 +48,7 @@ #' method.args = list(family = binomial), #' package = "lme4" #' ) |> -#' broom::tidy() +#' broom.mixed::tidy() #' #' construct_model( #' x = mtcars |> dplyr::rename(`M P G` = mpg), diff --git a/man/construction_helpers.Rd b/man/construction_helpers.Rd index 436bdd095..663dd63f3 100644 --- a/man/construction_helpers.Rd +++ b/man/construction_helpers.Rd @@ -114,7 +114,7 @@ construct_model( method.args = list(family = binomial), package = "lme4" ) |> - broom::tidy() + broom.mixed::tidy() construct_model( x = mtcars |> dplyr::rename(`M P G` = mpg), From eb01b6f5a89943f187bc02e05fa988a939747a0d Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 15 May 2024 11:19:59 -0700 Subject: [PATCH 17/24] Update construction_helpers.Rd --- man/construction_helpers.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/construction_helpers.Rd b/man/construction_helpers.Rd index 663dd63f3..9e4793c38 100644 --- a/man/construction_helpers.Rd +++ b/man/construction_helpers.Rd @@ -106,7 +106,7 @@ names that contain a space are wrapped in backticks. } } \examples{ -\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("withr", "lme4", "broom.helpers"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("withr", "lme4", "broom.helpers", "broom.mixed"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} construct_model( x = mtcars, formula = am ~ mpg + (1 | vs), From f504bef2444a802f7cedaf8bdc3fb401e4e9fd0f Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Wed, 15 May 2024 18:21:03 +0000 Subject: [PATCH 18/24] [skip actions] Bump version to 0.1.0.9042 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 244c76133..f2e66a110 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9041 +Version: 0.1.0.9042 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 068dd38a5..2459929a0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9041 +# cardx 0.1.0.9042 ### Breaking Changes From 3973772b377ede8ae51912f2c888b2071bb5285b Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 22 May 2024 14:04:52 -0700 Subject: [PATCH 19/24] Making `ard_survey_svycontinuous()` a S3 method (#150) **What changes are proposed in this pull request?** Converted `ard_survey_svycontinuous()` to a S3 method `ard_continuous.survey.design()`. -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [x] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [x] If a bug was fixed, a unit test was added. - [x] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [x] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [x] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [x] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- DESCRIPTION | 6 +-- NAMESPACE | 13 +++++- NEWS.md | 3 +- R/ard_attributes.survey.design.R | 37 +++++++++++++++ ...nuous.R => ard_continuous.survey.design.R} | 15 +++--- R/reexports.R | 21 +++++++++ _pkgdown.yml | 3 +- man/ard_attributes.Rd | 46 +++++++++++++++++++ ...ous.Rd => ard_continuous.survey.design.Rd} | 15 +++--- man/reexports.Rd | 7 +++ ...ous.md => ard_continuous.survey.design.md} | 17 ++++--- .../test-ard_attributes.survey.design.R | 17 +++++++ ....R => test-ard_continuous.survey.design.R} | 34 +++++++------- 13 files changed, 190 insertions(+), 44 deletions(-) create mode 100644 R/ard_attributes.survey.design.R rename R/{ard_survey_svycontinuous.R => ard_continuous.survey.design.R} (95%) create mode 100644 man/ard_attributes.Rd rename man/{ard_survey_svycontinuous.Rd => ard_continuous.survey.design.Rd} (88%) rename tests/testthat/_snaps/{ard_survey_svycontinuous.md => ard_continuous.survey.design.md} (77%) create mode 100644 tests/testthat/test-ard_attributes.survey.design.R rename tests/testthat/{test-ard_survey_svycontinuous.R => test-ard_continuous.survey.design.R} (93%) diff --git a/DESCRIPTION b/DESCRIPTION index f2e66a110..d94ccaa3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ BugReports: https://github.com/insightsengineering/cardx/issues Depends: R (>= 4.1) Imports: - cards (>= 0.1.0.9014), + cards (>= 0.1.0.9026), cli (>= 3.6.1), dplyr (>= 1.1.2), glue (>= 1.6.2), @@ -33,13 +33,13 @@ Suggests: effectsize (>= 0.6.0), emmeans (>= 1.7.3), geepack (>= 1.3.2), - ggsurvfit (>= 1.0.0), + ggsurvfit (>= 1.1.0), lme4 (>= 1.1-31), parameters (>= 0.20.2), smd (>= 0.6.6), spelling, survey (>= 4.1), - survival (>= 3.2-11), + survival (>= 3.6-4), testthat (>= 3.2.0), withr (>= 2.5.0) Remotes: diff --git a/NAMESPACE b/NAMESPACE index d1e1abdba..43f5d3d5c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(ard_attributes,survey.design) +S3method(ard_continuous,survey.design) S3method(ard_regression,default) S3method(ard_stats_anova,anova) S3method(ard_stats_anova,data.frame) @@ -9,13 +11,18 @@ export("%>%") export(all_of) export(any_of) export(ard_aod_wald_test) +export(ard_attributes) export(ard_car_anova) export(ard_car_vif) +export(ard_categorical) +export(ard_continuous) +export(ard_dichotomous) export(ard_effectsize_cohens_d) export(ard_effectsize_hedges_g) export(ard_effectsize_paired_cohens_d) export(ard_effectsize_paired_hedges_g) export(ard_emmeans_mean_difference) +export(ard_missing) export(ard_proportion_ci) export(ard_regression) export(ard_regression_basic) @@ -35,7 +42,6 @@ export(ard_stats_prop_test) export(ard_stats_t_test) export(ard_stats_wilcox_test) export(ard_survey_svychisq) -export(ard_survey_svycontinuous) export(ard_survey_svyranktest) export(ard_survey_svyttest) export(ard_survival_survdiff) @@ -60,6 +66,11 @@ export(reformulate2) export(starts_with) export(where) import(rlang) +importFrom(cards,ard_attributes) +importFrom(cards,ard_categorical) +importFrom(cards,ard_continuous) +importFrom(cards,ard_dichotomous) +importFrom(cards,ard_missing) importFrom(dplyr,"%>%") importFrom(dplyr,across) importFrom(dplyr,all_of) diff --git a/NEWS.md b/NEWS.md index 2459929a0..4aa1adcc2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -30,7 +30,8 @@ ard_moodtest() -> ard_stats_mood_test() - `ard_regression_basic()` for basic regression models. The function focuses on matching terms to underlying variables names. (#46) - `ard_smd_smd()` for calculating standardized mean differences using `smd::smd()`. (#4) - `ard_survival_survfit()` for survival analyses using `survival::survfit()`. (#43) - - `ard_survey_svycontinuous()` for calculating univariate summary statistics from weighted/survey data using many functions from the {survey} package. (#68) + - `ard_continuous.survey.design()` for calculating univariate summary statistics from weighted/survey data using many functions from the {survey} package. (#68) + - `ard_attributes.survey.design()` for summarizing labels and attributes from weighted/survey data using many functions from the {survey} package. - `ard_survey_svychisq()` for weighted/survey chi-squared test using `survey::svychisq()`. (#72) - `ard_survey_svyttest()` for weighted/survey t-tests using `survey::svyttest()`. (#70) - `ard_survey_svyranktest()` for weighted/survey rank tests using `survey::svyranktest()`. (#71) diff --git a/R/ard_attributes.survey.design.R b/R/ard_attributes.survey.design.R new file mode 100644 index 000000000..b3f069768 --- /dev/null +++ b/R/ard_attributes.survey.design.R @@ -0,0 +1,37 @@ +#' ARD Attributes +#' +#' @description +#' Add variable attributes to an ARD data frame. +#' - The `label` attribute will be added for all columns, and when no label +#' is specified and no label has been set for a column using the `label=` argument, +#' the column name will be placed in the label statistic. +#' - The `class` attribute will also be returned for all columns. +#' - Any other attribute returned by `attributes()` will also be added, e.g. factor levels. +#' +#' @rdname ard_attributes +#' @param data (`survey.design`)\cr +#' a design object often created with [`survey::svydesign()`]. +#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr +#' variables to include +#' @param label (named `list`)\cr +#' named list of variable labels, e.g. `list(cyl = "No. Cylinders")`. +#' Default is `NULL` +#' @inheritParams rlang::args_dots_empty +#' +#' @return an ARD data frame of class 'card' +#' @export +#' +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "survey", reference_pkg = "cardx")) +#' data(api, package = "survey") +#' dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) +#' +#' ard_attributes( +#' data = dclus1, +#' variables = c(sname, dname), +#' label = list(sname = "School Name", dname = "District Name") +#' ) +ard_attributes.survey.design <- function(data, variables = everything(), label = NULL, ...) { + set_cli_abort_call() + + cards::ard_attributes(data = data[["variables"]], variables = {{ variables }}, label = label, ...) +} diff --git a/R/ard_survey_svycontinuous.R b/R/ard_continuous.survey.design.R similarity index 95% rename from R/ard_survey_svycontinuous.R rename to R/ard_continuous.survey.design.R index 16d51fd5d..77c5b2b84 100644 --- a/R/ard_survey_svycontinuous.R +++ b/R/ard_continuous.survey.design.R @@ -23,6 +23,7 @@ #' the list element is either a named list or a list of formulas defining the #' statistic labels, e.g. `everything() ~ list(mean = "Mean", sd = "SD")` or #' `everything() ~ list(mean ~ "Mean", sd ~ "SD")`. +#' @inheritParams rlang::args_dots_empty #' #' @section statistic argument: #' @@ -38,16 +39,18 @@ #' data(api, package = "survey") #' dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) #' -#' ard_survey_svycontinuous( +#' ard_continuous( #' data = dclus1, #' variables = api00, #' by = stype #' ) -ard_survey_svycontinuous <- function(data, variables, by = NULL, - statistic = everything() ~ c("median", "p25", "p75"), - fmt_fn = NULL, - stat_label = NULL) { +ard_continuous.survey.design <- function(data, variables, by = NULL, + statistic = everything() ~ c("median", "p25", "p75"), + fmt_fn = NULL, + stat_label = NULL, + ...) { set_cli_abort_call() + check_dots_empty() # check installed packages --------------------------------------------------- check_pkg_installed(pkg = "survey", reference_pkg = "cardx") @@ -68,7 +71,7 @@ ard_survey_svycontinuous <- function(data, variables, by = NULL, ) cards::fill_formula_selectors( data$variables[variables], - statistic = formals(ard_survey_svycontinuous)[["statistic"]] |> eval() + statistic = formals(asNamespace("cardx")[["ard_continuous.survey.design"]])[["statistic"]] |> eval() ) cards::check_list_elements( x = statistic, diff --git a/R/reexports.R b/R/reexports.R index a7ae12e44..adc647104 100644 --- a/R/reexports.R +++ b/R/reexports.R @@ -1,3 +1,24 @@ +# cards ------------------------------------------------------------------------ +#' @importFrom cards ard_continuous +#' @export +cards::ard_continuous + +#' @importFrom cards ard_categorical +#' @export +cards::ard_categorical + +#' @importFrom cards ard_dichotomous +#' @export +cards::ard_dichotomous + +#' @importFrom cards ard_missing +#' @export +cards::ard_missing + +#' @importFrom cards ard_attributes +#' @export +cards::ard_attributes + # dplyr ------------------------------------------------------------------------ #' @export #' @importFrom dplyr %>% diff --git a/_pkgdown.yml b/_pkgdown.yml index a1acfa498..2e5965d2d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -60,8 +60,9 @@ reference: - subtitle: "{survey} package" - contents: + - ard_continuous.survey.design + - ard_attributes.survey.design - ard_survey_svychisq - - ard_survey_svycontinuous - ard_survey_svyranktest - ard_survey_svyttest diff --git a/man/ard_attributes.Rd b/man/ard_attributes.Rd new file mode 100644 index 000000000..6069aae4d --- /dev/null +++ b/man/ard_attributes.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ard_attributes.survey.design.R +\name{ard_attributes.survey.design} +\alias{ard_attributes.survey.design} +\title{ARD Attributes} +\usage{ +\method{ard_attributes}{survey.design}(data, variables = everything(), label = NULL, ...) +} +\arguments{ +\item{data}{(\code{survey.design})\cr +a design object often created with \code{\link[survey:svydesign]{survey::svydesign()}}.} + +\item{variables}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr +variables to include} + +\item{label}{(named \code{list})\cr +named list of variable labels, e.g. \code{list(cyl = "No. Cylinders")}. +Default is \code{NULL}} + +\item{...}{These dots are for future extensions and must be empty.} +} +\value{ +an ARD data frame of class 'card' +} +\description{ +Add variable attributes to an ARD data frame. +\itemize{ +\item The \code{label} attribute will be added for all columns, and when no label +is specified and no label has been set for a column using the \verb{label=} argument, +the column name will be placed in the label statistic. +\item The \code{class} attribute will also be returned for all columns. +\item Any other attribute returned by \code{attributes()} will also be added, e.g. factor levels. +} +} +\examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "survey", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(api, package = "survey") +dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) + +ard_attributes( + data = dclus1, + variables = c(sname, dname), + label = list(sname = "School Name", dname = "District Name") +) +\dontshow{\}) # examplesIf} +} diff --git a/man/ard_survey_svycontinuous.Rd b/man/ard_continuous.survey.design.Rd similarity index 88% rename from man/ard_survey_svycontinuous.Rd rename to man/ard_continuous.survey.design.Rd index 8e5df93d2..6ba18722a 100644 --- a/man/ard_survey_svycontinuous.Rd +++ b/man/ard_continuous.survey.design.Rd @@ -1,16 +1,17 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ard_survey_svycontinuous.R -\name{ard_survey_svycontinuous} -\alias{ard_survey_svycontinuous} +% Please edit documentation in R/ard_continuous.survey.design.R +\name{ard_continuous.survey.design} +\alias{ard_continuous.survey.design} \title{ARD Continuous Survey Statistics} \usage{ -ard_survey_svycontinuous( +\method{ard_continuous}{survey.design}( data, variables, by = NULL, statistic = everything() ~ c("median", "p25", "p75"), fmt_fn = NULL, - stat_label = NULL + stat_label = NULL, + ... ) } \arguments{ @@ -40,6 +41,8 @@ a named list, a list of formulas, or a single formula where the list element is either a named list or a list of formulas defining the statistic labels, e.g. \code{everything() ~ list(mean = "Mean", sd = "SD")} or \code{everything() ~ list(mean ~ "Mean", sd ~ "SD")}.} + +\item{...}{These dots are for future extensions and must be empty.} } \value{ an ARD data frame of class 'card' @@ -60,7 +63,7 @@ where 'p##' is are the percentiles and \verb{##} is an integer between 0 and 100 data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) -ard_survey_svycontinuous( +ard_continuous( data = dclus1, variables = api00, by = stype diff --git a/man/reexports.Rd b/man/reexports.Rd index 12e1f5269..927068d41 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -3,6 +3,11 @@ \docType{import} \name{reexports} \alias{reexports} +\alias{ard_continuous} +\alias{ard_categorical} +\alias{ard_dichotomous} +\alias{ard_missing} +\alias{ard_attributes} \alias{\%>\%} \alias{starts_with} \alias{ends_with} @@ -22,6 +27,8 @@ These objects are imported from other packages. Follow the links below to see their documentation. \describe{ + \item{cards}{\code{\link[cards]{ard_attributes}}, \code{\link[cards]{ard_categorical}}, \code{\link[cards]{ard_continuous}}, \code{\link[cards]{ard_dichotomous}}, \code{\link[cards]{ard_missing}}} + \item{dplyr}{\code{\link[dplyr:reexports]{\%>\%}}, \code{\link[dplyr:reexports]{all_of}}, \code{\link[dplyr:reexports]{any_of}}, \code{\link[dplyr:reexports]{contains}}, \code{\link[dplyr:reexports]{ends_with}}, \code{\link[dplyr:reexports]{everything}}, \code{\link[dplyr:reexports]{last_col}}, \code{\link[dplyr:reexports]{matches}}, \code{\link[dplyr:reexports]{num_range}}, \code{\link[dplyr:reexports]{one_of}}, \code{\link[dplyr:reexports]{starts_with}}, \code{\link[dplyr:reexports]{where}}} }} diff --git a/tests/testthat/_snaps/ard_survey_svycontinuous.md b/tests/testthat/_snaps/ard_continuous.survey.design.md similarity index 77% rename from tests/testthat/_snaps/ard_survey_svycontinuous.md rename to tests/testthat/_snaps/ard_continuous.survey.design.md index 7dbd96603..348621925 100644 --- a/tests/testthat/_snaps/ard_survey_svycontinuous.md +++ b/tests/testthat/_snaps/ard_continuous.survey.design.md @@ -1,4 +1,4 @@ -# unstratified ard_survey_svycontinuous() works +# unstratified ard_continuous.survey.design() works Code ard_uni_svy_cont @@ -19,12 +19,11 @@ Message i 2 more variables: warning, error -# ard_survey_svycontinuous(fmt_fn) +# ard_continuous.survey.design(fmt_fn) Code - ard_survey_svycontinuous(dclus1, variables = api00, statistic = ~ c("mean", - "median", "min", "max"), fmt_fn = list(api00 = list(mean = 2, median = "xx.xx", - min = as.character))) + ard_continuous(dclus1, variables = api00, statistic = ~ c("mean", "median", + "min", "max"), fmt_fn = list(api00 = list(mean = 2, median = "xx.xx", min = as.character))) Message {cards} data frame: 4 x 8 Output @@ -36,12 +35,12 @@ Message i 2 more variables: warning, error -# ard_survey_svycontinuous(stat_label) +# ard_continuous.survey.design(stat_label) Code - ard_survey_svycontinuous(dclus1, variables = api00, statistic = ~ c("mean", - "median", "min", "max"), stat_label = list(api00 = list(mean = "MeAn", - median = "MEDian", min = "MINimum"))) + ard_continuous(dclus1, variables = api00, statistic = ~ c("mean", "median", + "min", "max"), stat_label = list(api00 = list(mean = "MeAn", median = "MEDian", + min = "MINimum"))) Message {cards} data frame: 4 x 8 Output diff --git a/tests/testthat/test-ard_attributes.survey.design.R b/tests/testthat/test-ard_attributes.survey.design.R new file mode 100644 index 000000000..e4f663eec --- /dev/null +++ b/tests/testthat/test-ard_attributes.survey.design.R @@ -0,0 +1,17 @@ +skip_if_not(is_pkg_installed("survey", reference_pkg = "cardx")) + +test_that("ard_attributes.survey.design() works", { + data(api, package = "survey") + dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) + + expect_snapshot({ + attr(dclus1$variables$sname, "label") <- "School Name" + + ard_attributes( + dclus1, + variables = c(sname, dname), + label = list(dname = "District Name") + ) |> + as.data.frame() + }) +}) diff --git a/tests/testthat/test-ard_survey_svycontinuous.R b/tests/testthat/test-ard_continuous.survey.design.R similarity index 93% rename from tests/testthat/test-ard_survey_svycontinuous.R rename to tests/testthat/test-ard_continuous.survey.design.R index 85e737ce7..5b999d918 100644 --- a/tests/testthat/test-ard_survey_svycontinuous.R +++ b/tests/testthat/test-ard_continuous.survey.design.R @@ -1,12 +1,12 @@ skip_if_not(is_pkg_installed("survey", reference_pkg = "cardx")) -test_that("unstratified ard_survey_svycontinuous() works", { +test_that("unstratified ard_continuous.survey.design() works", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) expect_error( ard_uni_svy_cont <- - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, statistic = ~ c( @@ -71,13 +71,13 @@ test_that("unstratified ard_survey_svycontinuous() works", { }) -test_that("stratified ard_survey_svycontinuous() works", { +test_that("stratified ard_continuous.survey.design() works", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) expect_error( ard_svy_cont <- - ard_survey_svycontinuous( + ard_continuous( dclus1, by = both, variables = api00, @@ -238,13 +238,13 @@ test_that("stratified ard_survey_svycontinuous() works", { ) }) -test_that("ard_survey_svycontinuous() NA handling", { +test_that("ard_continuous.survey.design() NA handling", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1 |> dplyr::mutate(api00 = NA_real_), fpc = ~fpc) expect_error( ard_uni_NA_svy_cont <- - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, statistic = ~ c( @@ -263,7 +263,7 @@ test_that("ard_survey_svycontinuous() NA handling", { expect_error( ard_NA_svy_cont <- - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, by = both, @@ -282,7 +282,7 @@ test_that("ard_survey_svycontinuous() NA handling", { ) }) -test_that("ard_survey_svycontinuous() error handling", { +test_that("ard_continuous.survey.design() error handling", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1[1:20, ], fpc = ~fpc) @@ -290,7 +290,7 @@ test_that("ard_survey_svycontinuous() error handling", { # and these "results" may vary across systems (all are nonsense), so just check # that code runs without error expect_error( - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = sname, statistic = ~ c( @@ -302,7 +302,7 @@ test_that("ard_survey_svycontinuous() error handling", { ) expect_error( - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = sname, by = both, @@ -315,12 +315,12 @@ test_that("ard_survey_svycontinuous() error handling", { ) }) -test_that("ard_survey_svycontinuous(fmt_fn)", { +test_that("ard_continuous.survey.design(fmt_fn)", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) expect_snapshot( - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, statistic = ~ c("mean", "median", "min", "max"), @@ -329,12 +329,12 @@ test_that("ard_survey_svycontinuous(fmt_fn)", { ) }) -test_that("ard_survey_svycontinuous(stat_label)", { +test_that("ard_continuous.survey.design(stat_label)", { data(api, package = "survey") dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc) expect_snapshot( - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, statistic = ~ c("mean", "median", "min", "max"), @@ -343,7 +343,7 @@ test_that("ard_survey_svycontinuous(stat_label)", { ) }) -test_that("ard_survey_svycontinuous(by) unobserved levels/combinations", { +test_that("ard_continuous.survey.design(by) unobserved levels/combinations", { data(api, package = "survey") dclus1 <- survey::svydesign( id = ~dnum, weights = ~pw, @@ -359,7 +359,7 @@ test_that("ard_survey_svycontinuous(by) unobserved levels/combinations", { # The 'Neither' level is never observed, but included in the table expect_setequal( levels(dclus1$variables$both), - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, by = both, @@ -373,7 +373,7 @@ test_that("ard_survey_svycontinuous(by) unobserved levels/combinations", { # stype="E" is not observed with awards="No", but it should still appear in table with(dclus1$variables, table(stype, awards)) expect_equal( - ard_survey_svycontinuous( + ard_continuous( dclus1, variables = api00, by = c(stype, awards), From c99e8d78b9d7f648d8d7fbcf7a9a2dcca9c04b06 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Wed, 22 May 2024 21:05:46 +0000 Subject: [PATCH 20/24] [skip actions] Bump version to 0.1.0.9043 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d94ccaa3f..7143ed771 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9042 +Version: 0.1.0.9043 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 4aa1adcc2..1b3f8e7ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9042 +# cardx 0.1.0.9043 ### Breaking Changes From e2e448c34dddc2c450cab52692eefc2a6565f6ce Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Thu, 23 May 2024 13:58:50 -0700 Subject: [PATCH 21/24] Adding one-sample CI functions (#156) **What changes are proposed in this pull request?** - `ard_stats_wilcox_test_onesample()` for calculating one-sample results. - `ard_stats_t_test_onesample()` for calculating one-sample results. -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [x] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [x] If a bug was fixed, a unit test was added. - [x] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [x] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [x] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [x] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [x] If a bug was fixed, a unit test was added. - [x] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [x] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [x] Approve Pull Request - [x] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- NAMESPACE | 2 + NEWS.md | 2 + R/ard_stats_t_test_onesample.R | 71 ++++++++++++++++++ R/ard_stats_wilcox_test_onesample.R | 72 +++++++++++++++++++ README.Rmd | 2 +- README.md | 2 +- _pkgdown.yml | 2 + man/ard_stats_t_test_onesample.Rd | 43 +++++++++++ man/ard_stats_wilcox_test_onesample.Rd | 43 +++++++++++ .../test-ard_stats_t_test_onesample.R | 50 +++++++++++++ .../test-ard_stats_wilcox_test_onesample.R | 52 ++++++++++++++ 11 files changed, 339 insertions(+), 2 deletions(-) create mode 100644 R/ard_stats_t_test_onesample.R create mode 100644 R/ard_stats_wilcox_test_onesample.R create mode 100644 man/ard_stats_t_test_onesample.Rd create mode 100644 man/ard_stats_wilcox_test_onesample.Rd create mode 100644 tests/testthat/test-ard_stats_t_test_onesample.R create mode 100644 tests/testthat/test-ard_stats_wilcox_test_onesample.R diff --git a/NAMESPACE b/NAMESPACE index 43f5d3d5c..f222cfdee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -40,7 +40,9 @@ export(ard_stats_paired_t_test) export(ard_stats_paired_wilcox_test) export(ard_stats_prop_test) export(ard_stats_t_test) +export(ard_stats_t_test_onesample) export(ard_stats_wilcox_test) +export(ard_stats_wilcox_test_onesample) export(ard_survey_svychisq) export(ard_survey_svyranktest) export(ard_survey_svyttest) diff --git a/NEWS.md b/NEWS.md index 1b3f8e7ff..7b8e77c93 100644 --- a/NEWS.md +++ b/NEWS.md @@ -37,6 +37,8 @@ ard_moodtest() -> ard_stats_mood_test() - `ard_survey_svyranktest()` for weighted/survey rank tests using `survey::svyranktest()`. (#71) - `ard_car_vif()` for calculating the variance inflation factor using `car::vif()`. (#10) - `ard_emmeans_mean_difference()` for calculating the least-squares mean differences using the {emmeans} package. (#34) + - `ard_stats_wilcox_test_onesample()` for calculating one-sample results. + - `ard_stats_t_test_onesample()` for calculating one-sample results. * Updated functions `ard_stats_t_test()`, `ard_stats_paired_t_test()`, `ard_stats_wilcox_test()`, `ard_stats_paired_wilcox_test()`, `ard_stats_chisq_test()`, `ard_stats_fisher_test()`, `ard_stats_kruskal_test()`, `ard_stats_mcnemar_test()`, and `ard_stats_mood_test()` to accept multiple variables at once. Independent tests are calculated for each variable. The `variable` argument is renamed to `variables`. (#77) diff --git a/R/ard_stats_t_test_onesample.R b/R/ard_stats_t_test_onesample.R new file mode 100644 index 000000000..9eb8a79c0 --- /dev/null +++ b/R/ard_stats_t_test_onesample.R @@ -0,0 +1,71 @@ +#' ARD one-sample t-test +#' +#' @description +#' Analysis results data for one-sample t-tests. +#' Result may be stratified by including the `by` argument. +#' +#' @param data (`data.frame`)\cr +#' a data frame. See below for details. +#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr +#' column names to be analyzed. Independent t-tests will be computed for +#' each variable. +#' @param by ([`tidy-select`][dplyr::dplyr_tidy_select])\cr +#' optional column name to stratify results by. +#' @inheritParams ard_stats_t_test +#' +#' @return ARD data frame +#' @export +#' +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) +#' cards::ADSL |> +#' ard_stats_t_test_onesample(by = ARM, variables = AGE) +ard_stats_t_test_onesample <- function(data, variables, by = dplyr::group_vars(data), conf.level = 0.95, ...) { + set_cli_abort_call() + + # check installed packages --------------------------------------------------- + check_pkg_installed("broom", reference_pkg = "cardx") + + # check/process inputs ------------------------------------------------------- + check_not_missing(data) + check_not_missing(variables) + check_data_frame(data) + data <- dplyr::ungroup(data) + cards::process_selectors(data, by = {{ by }}, variables = {{ variables }}) + check_scalar_range(conf.level, range = c(0, 1)) + + # if no variables selected, return empty tibble ------------------------------ + if (is_empty(variables)) { + return(dplyr::tibble()) + } + + cards::ard_continuous( + data = data, + variables = all_of(variables), + by = all_of(by), + statistic = all_of(variables) ~ list(t_test_onesample = \(x) stats::t.test(x = x, conf.level = conf.level, ...) |> broom::tidy()) + ) |> + cards::bind_ard( + cards::ard_continuous( + data = data, + variables = all_of(variables), + by = all_of(by), + statistic = + all_of(variables) ~ + list(conf.level = \(x) { + formals(asNamespace("stats")[["t.test.default"]])["mu"] |> + utils::modifyList(list(conf.level = conf.level, ...)) + }) + ) + ) |> + dplyr::select(-"stat_label") |> + dplyr::left_join( + .df_ttest_stat_labels(by = NULL), + by = "stat_name" + ) |> + dplyr::mutate( + stat_label = dplyr::coalesce(.data$stat_label, .data$stat_name), + context = "ard_stats_t_test_onesample", + ) |> + cards::tidy_ard_row_order() |> + cards::tidy_ard_column_order() +} diff --git a/R/ard_stats_wilcox_test_onesample.R b/R/ard_stats_wilcox_test_onesample.R new file mode 100644 index 000000000..7741c2cab --- /dev/null +++ b/R/ard_stats_wilcox_test_onesample.R @@ -0,0 +1,72 @@ +#' ARD one-sample Wilcox Rank-sum +#' +#' @description +#' Analysis results data for one-sample Wilcox Rank-sum. +#' Result may be stratified by including the `by` argument. +#' +#' @param data (`data.frame`)\cr +#' a data frame. See below for details. +#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr +#' column names to be analyzed. Independent Wilcox Rank-sum tests will be computed for +#' each variable. +#' @param by ([`tidy-select`][dplyr::dplyr_tidy_select])\cr +#' optional column name to stratify results by. +#' @inheritParams ard_stats_wilcox_test +#' +#' @return ARD data frame +#' @export +#' +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) +#' cards::ADSL |> +#' ard_stats_wilcox_test_onesample(by = ARM, variables = AGE) +ard_stats_wilcox_test_onesample <- function(data, variables, by = dplyr::group_vars(data), conf.level = 0.95, ...) { + set_cli_abort_call() + + # check installed packages --------------------------------------------------- + check_pkg_installed("broom", reference_pkg = "cardx") + + # check/process inputs ------------------------------------------------------- + check_not_missing(data) + check_not_missing(variables) + check_data_frame(data) + data <- dplyr::ungroup(data) + cards::process_selectors(data, by = {{ by }}, variables = {{ variables }}) + check_scalar_range(conf.level, range = c(0, 1)) + + # if no variables selected, return empty tibble ------------------------------ + if (is_empty(variables)) { + return(dplyr::tibble()) + } + + cards::ard_continuous( + data = data, + variables = all_of(variables), + by = all_of(by), + statistic = all_of(variables) ~ list(t_test_onesample = \(x) stats::wilcox.test(x = x, conf.level = conf.level, ...) |> broom::tidy()) + ) |> + cards::bind_ard( + cards::ard_continuous( + data = data, + variables = all_of(variables), + by = all_of(by), + statistic = + all_of(variables) ~ + list(conf.level = \(x) { + formals(asNamespace("stats")[["wilcox.test.default"]])[c("mu", "exact", "conf.int", "tol.root", "digits.rank")] |> + utils::modifyList(list(conf.level = conf.level, ...)) |> + compact() + }) + ) + ) |> + dplyr::select(-"stat_label") |> + dplyr::left_join( + .df_ttest_stat_labels(by = NULL), + by = "stat_name" + ) |> + dplyr::mutate( + stat_label = dplyr::coalesce(.data$stat_label, .data$stat_name), + context = "ard_stats_wilcox_test_onesample", + ) |> + cards::tidy_ard_row_order() |> + cards::tidy_ard_column_order() +} diff --git a/README.Rmd b/README.Rmd index 8c2a55acf..0007ba337 100644 --- a/README.Rmd +++ b/README.Rmd @@ -5,7 +5,7 @@ editor_options: wrap: 72 --- -# cardx cardx website +# cardx cardx website [![R-CMD-check](https://github.com/insightsengineering/cardx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/insightsengineering/cardx/actions/workflows/R-CMD-check.yaml) [![Codecov test diff --git a/README.md b/README.md index 7c108b27a..fda5d4cff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# cardx cardx website +# cardx cardx website [![R-CMD-check](https://github.com/insightsengineering/cardx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/insightsengineering/cardx/actions/workflows/R-CMD-check.yaml) [![Codecov test diff --git a/_pkgdown.yml b/_pkgdown.yml index 2e5965d2d..b40a3879f 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -34,7 +34,9 @@ reference: - ard_stats_oneway_test - ard_stats_prop_test - ard_stats_t_test + - ard_stats_t_test_onesample - ard_stats_wilcox_test + - ard_stats_wilcox_test_onesample - subtitle: "{aod} package" - contents: diff --git a/man/ard_stats_t_test_onesample.Rd b/man/ard_stats_t_test_onesample.Rd new file mode 100644 index 000000000..26a53a373 --- /dev/null +++ b/man/ard_stats_t_test_onesample.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ard_stats_t_test_onesample.R +\name{ard_stats_t_test_onesample} +\alias{ard_stats_t_test_onesample} +\title{ARD one-sample t-test} +\usage{ +ard_stats_t_test_onesample( + data, + variables, + by = dplyr::group_vars(data), + conf.level = 0.95, + ... +) +} +\arguments{ +\item{data}{(\code{data.frame})\cr +a data frame. See below for details.} + +\item{variables}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr +column names to be analyzed. Independent t-tests will be computed for +each variable.} + +\item{by}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr +optional column name to stratify results by.} + +\item{conf.level}{(scalar \code{numeric})\cr +confidence level for confidence interval. Default is \code{0.95}.} + +\item{...}{arguments passed to \code{t.test(...)}} +} +\value{ +ARD data frame +} +\description{ +Analysis results data for one-sample t-tests. +Result may be stratified by including the \code{by} argument. +} +\examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +cards::ADSL |> + ard_stats_t_test_onesample(by = ARM, variables = AGE) +\dontshow{\}) # examplesIf} +} diff --git a/man/ard_stats_wilcox_test_onesample.Rd b/man/ard_stats_wilcox_test_onesample.Rd new file mode 100644 index 000000000..b01882559 --- /dev/null +++ b/man/ard_stats_wilcox_test_onesample.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ard_stats_wilcox_test_onesample.R +\name{ard_stats_wilcox_test_onesample} +\alias{ard_stats_wilcox_test_onesample} +\title{ARD one-sample Wilcox Rank-sum} +\usage{ +ard_stats_wilcox_test_onesample( + data, + variables, + by = dplyr::group_vars(data), + conf.level = 0.95, + ... +) +} +\arguments{ +\item{data}{(\code{data.frame})\cr +a data frame. See below for details.} + +\item{variables}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr +column names to be analyzed. Independent Wilcox Rank-sum tests will be computed for +each variable.} + +\item{by}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr +optional column name to stratify results by.} + +\item{conf.level}{(scalar \code{numeric})\cr +confidence level for confidence interval. Default is \code{0.95}.} + +\item{...}{arguments passed to \code{wilcox.test(...)}} +} +\value{ +ARD data frame +} +\description{ +Analysis results data for one-sample Wilcox Rank-sum. +Result may be stratified by including the \code{by} argument. +} +\examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +cards::ADSL |> + ard_stats_wilcox_test_onesample(by = ARM, variables = AGE) +\dontshow{\}) # examplesIf} +} diff --git a/tests/testthat/test-ard_stats_t_test_onesample.R b/tests/testthat/test-ard_stats_t_test_onesample.R new file mode 100644 index 000000000..df62e11c2 --- /dev/null +++ b/tests/testthat/test-ard_stats_t_test_onesample.R @@ -0,0 +1,50 @@ +skip_if_not(is_pkg_installed("broom", reference_pkg = "cardx")) + +test_that("ard_stats_t_test_onesample() works", { + # first calculate an object to test against + expect_silent( + ard1 <- ard_stats_t_test_onesample( + cards::ADSL, + variables = AGE, + by = ARM, + conf.level = 0.9, + mu = 1 + ) + ) + + # first check arguments passed and returned correctly + expect_equal( + cards::get_ard_statistics( + ard1, + group1_level %in% "Placebo" + )[c("mu", "conf.level")], + list(mu = 1, conf.level = 0.9) + ) + # check results are correct + expect_equal( + cards::get_ard_statistics( + ard1, + group1_level %in% "Placebo" + )[c("estimate", "conf.low", "conf.high", "p.value")], + t.test( + cards::ADSL$AGE[cards::ADSL$ARM == "Placebo"], + conf.level = 0.9, + mu = 1 + ) |> + broom::tidy() |> + dplyr::select(c("estimate", "conf.low", "conf.high", "p.value")) |> + as.list() + ) + + # test the structure is good + expect_silent(cards::check_ard_structure(ard1)) + + # empty tibble returned with no variables + expect_equal( + ard_stats_t_test_onesample( + cards::ADSL, + variables = character(0) + ), + dplyr::tibble() + ) +}) diff --git a/tests/testthat/test-ard_stats_wilcox_test_onesample.R b/tests/testthat/test-ard_stats_wilcox_test_onesample.R new file mode 100644 index 000000000..3bd22c238 --- /dev/null +++ b/tests/testthat/test-ard_stats_wilcox_test_onesample.R @@ -0,0 +1,52 @@ +skip_if_not(is_pkg_installed("broom", reference_pkg = "cardx")) + +test_that("ard_stats_wilcox_test_onesample() works", { + # first calculate an object to test against + expect_silent( + ard1 <- ard_stats_wilcox_test_onesample( + cards::ADSL, + variables = AGE, + by = ARM, + conf.level = 0.9, + conf.int = TRUE, + mu = 1 + ) + ) + + # first check arguments passed and returned correctly + expect_equal( + cards::get_ard_statistics( + ard1, + group1_level %in% "Placebo" + )[c("mu", "conf.level")], + list(mu = 1, conf.level = 0.9) + ) + # check results are correct + expect_equal( + cards::get_ard_statistics( + ard1, + group1_level %in% "Placebo" + )[c("estimate", "conf.low", "conf.high", "p.value")], + wilcox.test( + cards::ADSL$AGE[cards::ADSL$ARM == "Placebo"], + conf.level = 0.9, + mu = 1, + conf.int = TRUE + ) |> + broom::tidy() |> + dplyr::select(c("estimate", "conf.low", "conf.high", "p.value")) |> + as.list() + ) + + # test the structure is good + expect_silent(cards::check_ard_structure(ard1)) + + # empty tibble returned with no variables + expect_equal( + ard_stats_wilcox_test_onesample( + cards::ADSL, + variables = character(0) + ), + dplyr::tibble() + ) +}) From db48b77156c140ac33c69e776d859682cb5eb3cd Mon Sep 17 00:00:00 2001 From: edelarua Date: Thu, 23 May 2024 20:59:45 +0000 Subject: [PATCH 22/24] [skip actions] Bump version to 0.1.0.9044 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7143ed771..d14d89d55 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9043 +Version: 0.1.0.9044 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 7b8e77c93..02074f230 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9043 +# cardx 0.1.0.9044 ### Breaking Changes From 819dab496e1b76eb1ed5417d8d89a1822477038c Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Thu, 23 May 2024 18:39:06 -0400 Subject: [PATCH 23/24] Update `ard_survival_survfit` (#152) **What changes are proposed in this pull request?** * Updated `ard_survival_survfit` to return `std.error` and `n.risk` statistics. (#139 ) @ddsjoberg as I currently have it, `std.error` gets transformed along with `estimate`, `conf.low`, and `conf.high` (with options `"survival"`, `"cumhaz"`, and `"risk"`), but if you think it's more informative to always return the untransformed `std.error` that can be updated. Closes #139 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [x] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [x] If a bug was fixed, a unit test was added. - [x] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [x] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [x] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom", reference_pkg = "cardx")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom"", reference_pkg = "cardx"))` - [x] Code coverage is suitable for any new functions/features (generally, 100% coverage for new code): `devtools::test_coverage()` Reviewer Checklist (if item does not apply, mark is as complete) - [ ] If a bug was fixed, a unit test was added. - [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` When the branch is ready to be merged: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# cardx (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] **All** GitHub Action workflows pass with a :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_survival_survfit.R | 74 +++---- man/dot-process_survfit_time.Rd | 5 +- tests/testthat/_snaps/ard_survival_survfit.md | 194 +++++++++++------- 3 files changed, 154 insertions(+), 119 deletions(-) diff --git a/R/ard_survival_survfit.R b/R/ard_survival_survfit.R index 9a30adf5f..e430eedc0 100644 --- a/R/ard_survival_survfit.R +++ b/R/ard_survival_survfit.R @@ -111,6 +111,8 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { #' #' @inheritParams cards::tidy_as_ard #' @inheritParams ard_survival_survfit +#' @param start.time (`numeric`)\cr +#' default starting time. See [survival::survfit0()] for more details. #' #' @return a `tibble` #' @@ -119,42 +121,39 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { #' cardx:::.process_survfit_time(times = c(60, 180), type = "risk") #' #' @keywords internal -.process_survfit_time <- function(x, times, type) { - # tidy survfit results - tidy_x <- broom::tidy(x) +.process_survfit_time <- function(x, times, type, start.time = NULL) { + # add start time + min_time <- min(x$time) + if (is.null(start.time) && min_time < 0) { + cli::cli_inform(paste( + "The {.arg start.time} argument has not been set and negative times have been observed. Please set start", + "time via the {.arg start.time} argument, otherwise the minimum observed time will be used by default." + )) + start.time <- min_time + } else if (is.null(start.time)) { + start.time <- 0 + } + x <- survival::survfit0(x, start.time) %>% + summary(times) # process competing risks/multi-state models - multi_state <- inherits(x, "survfitms") + multi_state <- inherits(x, "summary.survfitms") - if (multi_state == TRUE) { + if (multi_state) { # selecting state to show - state <- setdiff(unique(tidy_x$state), "(s0)")[[1]] + state <- setdiff(unique(x$states), "(s0)")[[1]] cli::cli_inform("Multi-state model detected. Showing probabilities into state '{state}'.") - tidy_x <- dplyr::filter(tidy_x, .data$state == .env$state) + x$n.risk <- x$n.risk[, 1] + ms_cols <- c("pstate", "std.err", "upper", "lower") + state_col <- which(colnames(x$pstate) == state) + x[ms_cols] <- lapply(x[ms_cols], function(m) m[, state_col]) + x$surv <- x$pstate } - # adding time 0 to data frame - tidy_x <- tidy_x %>% - # make strata a fct to preserve ordering - dplyr::mutate(dplyr::across(dplyr::any_of("strata"), ~ factor(., levels = unique(.)))) %>% - # if CI is missing and SE is 0, use estimate as the CI - dplyr::mutate_at( - dplyr::vars("conf.high", "conf.low"), - ~ ifelse(is.na(.) & .data$std.error == 0, .data$estimate, .) - ) %>% - dplyr::select(dplyr::any_of(c("time", "estimate", "conf.high", "conf.low", "strata"))) %>% - # add data for time 0 - dplyr::bind_rows( - dplyr::group_by_at(., dplyr::vars(dplyr::any_of("strata"))) %>% - dplyr::slice(1) %>% - dplyr::mutate( - time = 0, - estimate = ifelse(multi_state, 0, 1), - conf.low = ifelse(multi_state, 0, 1), - conf.high = ifelse(multi_state, 0, 1) - ) - ) %>% - dplyr::ungroup() + # tidy survfit results + x_cols <- intersect(names(x), c("time", "n.risk", "surv", "std.err", "upper", "lower", "strata")) + tidy_x <- data.frame(x[x_cols]) %>% + dplyr::rename(estimate = "surv", std.error = "std.err", conf.high = "upper", conf.low = "lower") strat <- "strata" %in% names(tidy_x) @@ -182,16 +181,7 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { } df_stat <- df_stat %>% - # if user-specifed time is unobserved, fill estimate with previous value dplyr::arrange(.data$time) %>% - dplyr::group_by_at(dplyr::vars(dplyr::any_of("strata"))) %>% - tidyr::fill( - "estimate", "conf.high", "conf.low", "time_max", - .direction = "down" - ) %>% - dplyr::ungroup() %>% - # keep only user-specified times - dplyr::filter(!is.na(.data$col_name)) %>% # if user-specified time is after max time, make estimate NA dplyr::mutate_at( dplyr::vars("estimate", "conf.high", "conf.low"), @@ -236,7 +226,7 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { as.data.frame() %>% set_names(c("estimate", "conf.low", "conf.high")) %>% dplyr::mutate(strata = row.names(.)) %>% - dplyr::select(dplyr::any_of(c("strata", "estimate", "conf.low", "conf.high"))) %>% + dplyr::select(dplyr::any_of(c("n.risk", "strata", "estimate", "std.error", "conf.low", "conf.high"))) %>% dplyr::mutate(prob = .x) ) %>% dplyr::bind_rows() %>% @@ -293,10 +283,10 @@ extract_multi_strata <- function(x, df_stat) { ret <- tidy_survfit %>% dplyr::mutate(dplyr::across( - dplyr::any_of(c("estimate", "conf.high", "conf.low", "time", "prob")), ~ as.list(.) + dplyr::any_of(c("n.risk", "estimate", "std.error", "conf.high", "conf.low", "time", "prob")), ~ as.list(.) )) %>% tidyr::pivot_longer( - cols = dplyr::any_of(c("estimate", "conf.high", "conf.low")), + cols = dplyr::any_of(c("n.risk", "estimate", "std.error", "conf.high", "conf.low")), names_to = "stat_name", values_to = "stat" ) %>% @@ -342,7 +332,9 @@ extract_multi_strata <- function(x, df_stat) { .df_survfit_stat_labels <- function() { dplyr::tribble( ~stat_name, ~stat_label, + "n.risk", "Number of Subjects at Risk", "estimate", "Survival Probability", + "std.error", "Standard Error (untransformed)", "conf.low", "CI Lower Bound", "conf.high", "CI Upper Bound", "conf.level", "CI Confidence Level", diff --git a/man/dot-process_survfit_time.Rd b/man/dot-process_survfit_time.Rd index c6f9bee25..cc3b6682c 100644 --- a/man/dot-process_survfit_time.Rd +++ b/man/dot-process_survfit_time.Rd @@ -4,7 +4,7 @@ \alias{.process_survfit_time} \title{Process Survival Fit For Time Estimates} \usage{ -.process_survfit_time(x, times, type) +.process_survfit_time(x, times, type, start.time = NULL) } \arguments{ \item{x}{(\code{\link[survival:survfit]{survival::survfit()}})\cr @@ -22,6 +22,9 @@ Must be one of the following:\tabular{ll}{ \code{"risk"} \tab \code{1 - x} \cr \code{"cumhaz"} \tab \code{-log(x)} \cr }} + +\item{start.time}{(\code{numeric})\cr +default starting time. See \code{\link[survival:survfit0]{survival::survfit0()}} for more details.} } \value{ a \code{tibble} diff --git a/tests/testthat/_snaps/ard_survival_survfit.md b/tests/testthat/_snaps/ard_survival_survfit.md index 6697507dd..7f2a2529d 100644 --- a/tests/testthat/_snaps/ard_survival_survfit.md +++ b/tests/testthat/_snaps/ard_survival_survfit.md @@ -5,27 +5,39 @@ CNSR) ~ TRTA, cards::ADTTE), times = c(60, 180)), stat = lapply(stat, function(x) ifelse(is.numeric(x), cards::round5(x, 3), x))), n = Inf) Message - {cards} data frame: 18 x 11 + {cards} data frame: 30 x 11 Output group1 group1_level variable variable_level stat_name stat_label stat - 1 TRTA Placebo time 60 estimate Survival… 0.893 - 2 TRTA Placebo time 60 conf.high CI Upper… 0.966 - 3 TRTA Placebo time 60 conf.low CI Lower… 0.825 - 4 TRTA Placebo time 180 estimate Survival… 0.651 - 5 TRTA Placebo time 180 conf.high CI Upper… 0.783 - 6 TRTA Placebo time 180 conf.low CI Lower… 0.541 - 7 TRTA Xanomeli… time 60 estimate Survival… 0.694 - 8 TRTA Xanomeli… time 60 conf.high CI Upper… 0.849 - 9 TRTA Xanomeli… time 60 conf.low CI Lower… 0.568 - 10 TRTA Xanomeli… time 180 estimate Survival… 0.262 - 11 TRTA Xanomeli… time 180 conf.high CI Upper… 0.749 - 12 TRTA Xanomeli… time 180 conf.low CI Lower… 0.092 - 13 TRTA Xanomeli… time 60 estimate Survival… 0.732 - 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.878 - 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.61 - 16 TRTA Xanomeli… time 180 estimate Survival… 0.381 - 17 TRTA Xanomeli… time 180 conf.high CI Upper… 0.743 - 18 TRTA Xanomeli… time 180 conf.low CI Lower… 0.195 + 1 TRTA Placebo time 60 n.risk Number o… 59 + 2 TRTA Placebo time 60 estimate Survival… 0.893 + 3 TRTA Placebo time 60 std.error Standard… 0.036 + 4 TRTA Placebo time 60 conf.high CI Upper… 0.966 + 5 TRTA Placebo time 60 conf.low CI Lower… 0.825 + 6 TRTA Placebo time 180 n.risk Number o… 35 + 7 TRTA Placebo time 180 estimate Survival… 0.651 + 8 TRTA Placebo time 180 std.error Standard… 0.061 + 9 TRTA Placebo time 180 conf.high CI Upper… 0.783 + 10 TRTA Placebo time 180 conf.low CI Lower… 0.541 + 11 TRTA Xanomeli… time 60 n.risk Number o… 14 + 12 TRTA Xanomeli… time 60 estimate Survival… 0.694 + 13 TRTA Xanomeli… time 60 std.error Standard… 0.071 + 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.849 + 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.568 + 16 TRTA Xanomeli… time 180 n.risk Number o… 3 + 17 TRTA Xanomeli… time 180 estimate Survival… 0.262 + 18 TRTA Xanomeli… time 180 std.error Standard… 0.14 + 19 TRTA Xanomeli… time 180 conf.high CI Upper… 0.749 + 20 TRTA Xanomeli… time 180 conf.low CI Lower… 0.092 + 21 TRTA Xanomeli… time 60 n.risk Number o… 20 + 22 TRTA Xanomeli… time 60 estimate Survival… 0.732 + 23 TRTA Xanomeli… time 60 std.error Standard… 0.068 + 24 TRTA Xanomeli… time 60 conf.high CI Upper… 0.878 + 25 TRTA Xanomeli… time 60 conf.low CI Lower… 0.61 + 26 TRTA Xanomeli… time 180 n.risk Number o… 5 + 27 TRTA Xanomeli… time 180 estimate Survival… 0.381 + 28 TRTA Xanomeli… time 180 std.error Standard… 0.13 + 29 TRTA Xanomeli… time 180 conf.high CI Upper… 0.743 + 30 TRTA Xanomeli… time 180 conf.low CI Lower… 0.195 Message i 4 more variables: context, fmt_fn, warning, error @@ -36,27 +48,39 @@ CNSR) ~ TRTA, cards::ADTTE), times = c(60, 180), type = "risk"), stat = lapply( stat, function(x) ifelse(is.numeric(x), cards::round5(x, 3), x))), n = Inf) Message - {cards} data frame: 18 x 11 + {cards} data frame: 30 x 11 Output group1 group1_level variable variable_level stat_name stat_label stat - 1 TRTA Placebo time 60 estimate Survival… 0.107 - 2 TRTA Placebo time 60 conf.high CI Upper… 0.175 - 3 TRTA Placebo time 60 conf.low CI Lower… 0.034 - 4 TRTA Placebo time 180 estimate Survival… 0.349 - 5 TRTA Placebo time 180 conf.high CI Upper… 0.459 - 6 TRTA Placebo time 180 conf.low CI Lower… 0.217 - 7 TRTA Xanomeli… time 60 estimate Survival… 0.306 - 8 TRTA Xanomeli… time 60 conf.high CI Upper… 0.432 - 9 TRTA Xanomeli… time 60 conf.low CI Lower… 0.151 - 10 TRTA Xanomeli… time 180 estimate Survival… 0.738 - 11 TRTA Xanomeli… time 180 conf.high CI Upper… 0.908 - 12 TRTA Xanomeli… time 180 conf.low CI Lower… 0.251 - 13 TRTA Xanomeli… time 60 estimate Survival… 0.268 - 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.39 - 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.122 - 16 TRTA Xanomeli… time 180 estimate Survival… 0.619 - 17 TRTA Xanomeli… time 180 conf.high CI Upper… 0.805 - 18 TRTA Xanomeli… time 180 conf.low CI Lower… 0.257 + 1 TRTA Placebo time 60 n.risk Number o… 59 + 2 TRTA Placebo time 60 estimate Survival… 0.107 + 3 TRTA Placebo time 60 std.error Standard… 0.036 + 4 TRTA Placebo time 60 conf.high CI Upper… 0.175 + 5 TRTA Placebo time 60 conf.low CI Lower… 0.034 + 6 TRTA Placebo time 180 n.risk Number o… 35 + 7 TRTA Placebo time 180 estimate Survival… 0.349 + 8 TRTA Placebo time 180 std.error Standard… 0.061 + 9 TRTA Placebo time 180 conf.high CI Upper… 0.459 + 10 TRTA Placebo time 180 conf.low CI Lower… 0.217 + 11 TRTA Xanomeli… time 60 n.risk Number o… 14 + 12 TRTA Xanomeli… time 60 estimate Survival… 0.306 + 13 TRTA Xanomeli… time 60 std.error Standard… 0.071 + 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.432 + 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.151 + 16 TRTA Xanomeli… time 180 n.risk Number o… 3 + 17 TRTA Xanomeli… time 180 estimate Survival… 0.738 + 18 TRTA Xanomeli… time 180 std.error Standard… 0.14 + 19 TRTA Xanomeli… time 180 conf.high CI Upper… 0.908 + 20 TRTA Xanomeli… time 180 conf.low CI Lower… 0.251 + 21 TRTA Xanomeli… time 60 n.risk Number o… 20 + 22 TRTA Xanomeli… time 60 estimate Survival… 0.268 + 23 TRTA Xanomeli… time 60 std.error Standard… 0.068 + 24 TRTA Xanomeli… time 60 conf.high CI Upper… 0.39 + 25 TRTA Xanomeli… time 60 conf.low CI Lower… 0.122 + 26 TRTA Xanomeli… time 180 n.risk Number o… 5 + 27 TRTA Xanomeli… time 180 estimate Survival… 0.619 + 28 TRTA Xanomeli… time 180 std.error Standard… 0.13 + 29 TRTA Xanomeli… time 180 conf.high CI Upper… 0.805 + 30 TRTA Xanomeli… time 180 conf.low CI Lower… 0.257 Message i 4 more variables: context, fmt_fn, warning, error @@ -98,15 +122,19 @@ status) ~ 1, data = survival::lung), times = c(60, 180)), stat = lapply(stat, function(x) ifelse(is.numeric(x), cards::round5(x, 3), x))), n = Inf) Message - {cards} data frame: 6 x 9 + {cards} data frame: 10 x 9 Output - variable variable_level context stat_name stat_label stat - 1 time 60 survival estimate Survival… 0.925 - 2 time 60 survival conf.high CI Upper… 0.96 - 3 time 60 survival conf.low CI Lower… 0.892 - 4 time 180 survival estimate Survival… 0.722 - 5 time 180 survival conf.high CI Upper… 0.783 - 6 time 180 survival conf.low CI Lower… 0.666 + variable variable_level context stat_name stat_label stat + 1 time 60 survival n.risk Number o… 213 + 2 time 60 survival estimate Survival… 0.925 + 3 time 60 survival std.error Standard… 0.017 + 4 time 60 survival conf.high CI Upper… 0.96 + 5 time 60 survival conf.low CI Lower… 0.892 + 6 time 180 survival n.risk Number o… 160 + 7 time 180 survival estimate Survival… 0.722 + 8 time 180 survival std.error Standard… 0.03 + 9 time 180 survival conf.high CI Upper… 0.783 + 10 time 180 survival conf.low CI Lower… 0.666 Message i 3 more variables: fmt_fn, warning, error @@ -146,20 +174,20 @@ 4 sex 1 ph.ecog 0 5 sex 1 ph.ecog 0 6 sex 1 ph.ecog 0 - 7 sex 1 ph.ecog 1 - 8 sex 1 ph.ecog 1 - 9 sex 1 ph.ecog 1 - 10 sex 1 ph.ecog 1 + 7 sex 1 ph.ecog 0 + 8 sex 1 ph.ecog 0 + 9 sex 1 ph.ecog 0 + 10 sex 1 ph.ecog 0 11 sex 1 ph.ecog 1 12 sex 1 ph.ecog 1 - 13 sex 1 ph.ecog 2 - 14 sex 1 ph.ecog 2 - 15 sex 1 ph.ecog 2 - 16 sex 1 ph.ecog 2 - 17 sex 1 ph.ecog 2 - 18 sex 1 ph.ecog 2 - 19 sex 1 ph.ecog 3 - 20 sex 1 ph.ecog 3 + 13 sex 1 ph.ecog 1 + 14 sex 1 ph.ecog 1 + 15 sex 1 ph.ecog 1 + 16 sex 1 ph.ecog 1 + 17 sex 1 ph.ecog 1 + 18 sex 1 ph.ecog 1 + 19 sex 1 ph.ecog 1 + 20 sex 1 ph.ecog 1 --- @@ -201,27 +229,39 @@ ifelse(is.numeric(x), cards::round5(x, 3), x))), n = Inf) Message Multi-state model detected. Showing probabilities into state 'death from cancer'. - {cards} data frame: 18 x 11 + {cards} data frame: 30 x 11 Output group1 group1_level variable variable_level stat_name stat_label stat - 1 TRTA Placebo time 60 estimate Survival… 0.054 - 2 TRTA Placebo time 60 conf.high CI Upper… 0.14 - 3 TRTA Placebo time 60 conf.low CI Lower… 0.021 - 4 TRTA Placebo time 180 estimate Survival… 0.226 - 5 TRTA Placebo time 180 conf.high CI Upper… 0.361 - 6 TRTA Placebo time 180 conf.low CI Lower… 0.142 - 7 TRTA Xanomeli… time 60 estimate Survival… 0.137 - 8 TRTA Xanomeli… time 60 conf.high CI Upper… 0.311 - 9 TRTA Xanomeli… time 60 conf.low CI Lower… 0.06 - 10 TRTA Xanomeli… time 180 estimate Survival… 0.51 - 11 TRTA Xanomeli… time 180 conf.high CI Upper… 0.892 - 12 TRTA Xanomeli… time 180 conf.low CI Lower… 0.292 - 13 TRTA Xanomeli… time 60 estimate Survival… 0.162 - 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.33 - 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.08 - 16 TRTA Xanomeli… time 180 estimate Survival… 0.244 - 17 TRTA Xanomeli… time 180 conf.high CI Upper… 0.516 - 18 TRTA Xanomeli… time 180 conf.low CI Lower… 0.115 + 1 TRTA Placebo time 60 n.risk Number o… 59 + 2 TRTA Placebo time 60 estimate Survival… 0.054 + 3 TRTA Placebo time 60 std.error Standard… 0.026 + 4 TRTA Placebo time 60 conf.high CI Upper… 0.14 + 5 TRTA Placebo time 60 conf.low CI Lower… 0.021 + 6 TRTA Placebo time 180 n.risk Number o… 35 + 7 TRTA Placebo time 180 estimate Survival… 0.226 + 8 TRTA Placebo time 180 std.error Standard… 0.054 + 9 TRTA Placebo time 180 conf.high CI Upper… 0.361 + 10 TRTA Placebo time 180 conf.low CI Lower… 0.142 + 11 TRTA Xanomeli… time 60 n.risk Number o… 14 + 12 TRTA Xanomeli… time 60 estimate Survival… 0.137 + 13 TRTA Xanomeli… time 60 std.error Standard… 0.057 + 14 TRTA Xanomeli… time 60 conf.high CI Upper… 0.311 + 15 TRTA Xanomeli… time 60 conf.low CI Lower… 0.06 + 16 TRTA Xanomeli… time 180 n.risk Number o… 3 + 17 TRTA Xanomeli… time 180 estimate Survival… 0.51 + 18 TRTA Xanomeli… time 180 std.error Standard… 0.145 + 19 TRTA Xanomeli… time 180 conf.high CI Upper… 0.892 + 20 TRTA Xanomeli… time 180 conf.low CI Lower… 0.292 + 21 TRTA Xanomeli… time 60 n.risk Number o… 20 + 22 TRTA Xanomeli… time 60 estimate Survival… 0.162 + 23 TRTA Xanomeli… time 60 std.error Standard… 0.059 + 24 TRTA Xanomeli… time 60 conf.high CI Upper… 0.33 + 25 TRTA Xanomeli… time 60 conf.low CI Lower… 0.08 + 26 TRTA Xanomeli… time 180 n.risk Number o… 5 + 27 TRTA Xanomeli… time 180 estimate Survival… 0.244 + 28 TRTA Xanomeli… time 180 std.error Standard… 0.093 + 29 TRTA Xanomeli… time 180 conf.high CI Upper… 0.516 + 30 TRTA Xanomeli… time 180 conf.low CI Lower… 0.115 Message i 4 more variables: context, fmt_fn, warning, error From 3752d8a2194f596ea4db3a761d171ca5166ab54b Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Thu, 23 May 2024 22:39:58 +0000 Subject: [PATCH 24/24] [skip actions] Bump version to 0.1.0.9045 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d14d89d55..8796c618a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9044 +Version: 0.1.0.9045 Authors@R: c( person("Daniel", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre")), person("Abinaya", "Yogasekaram", , "abinaya.yogasekaram@contractors.roche.com", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 02074f230..0deb3bce5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9044 +# cardx 0.1.0.9045 ### Breaking Changes