From 21f53c35a9083c056ae76783b69cc5c711a65a62 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Sun, 21 Apr 2024 03:44:05 +0000 Subject: [PATCH 1/3] [skip actions] Bump version to 0.1.0.9026 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index da3fe09d3..b2513dca0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9025 +Version: 0.1.0.9026 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 6330f0f0e..3d3bbea01 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9025 +# cardx 0.1.0.9026 ### Breaking Changes From a77becf561a2cce689d769135a6890a1cf173b2b Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:20:42 -0400 Subject: [PATCH 2/3] Remove all-NA `variable_level` column from regression ARD output (#135) **What changes are proposed in this pull request?** * Removed all-NA `variable_level` column from regression ARDs constructed from simple linear regression models. (#134) Also fixed failing example for `construct_model` which uses `ard_regression` but did not require `broom.helpers` to be installed. Closes #134 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **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_regression.R | 1 + R/ard_regression_basic.R | 3 ++- R/construction_helpers.R | 2 +- man/construction_helpers.Rd | 2 +- tests/testthat/_snaps/construction_helpers.md | 14 +++++++------- tests/testthat/test-ard_regression.R | 4 ++++ tests/testthat/test-ard_regression_basic.R | 4 ++++ tests/testthat/test-construction_helpers.R | 2 +- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/R/ard_regression.R b/R/ard_regression.R index a7b0561cb..f07fabc7d 100644 --- a/R/ard_regression.R +++ b/R/ard_regression.R @@ -49,6 +49,7 @@ ard_regression.default <- function(x, tidy_fun = broom.helpers::tidy_with_broom_ values_to = "stat" ) |> dplyr::filter(map_lgl(.data$stat, Negate(is.na))) |> + dplyr::select(-(cards::all_ard_variables("levels") & dplyr::where(\(x) all(is.na(x))))) |> dplyr::mutate( fmt_fn = lapply( diff --git a/R/ard_regression_basic.R b/R/ard_regression_basic.R index e923245fb..c9a5b3ebe 100644 --- a/R/ard_regression_basic.R +++ b/R/ard_regression_basic.R @@ -55,5 +55,6 @@ ard_regression_basic <- function(x, tidy_fun = broom.helpers::tidy_with_broom_or utils::modifyList(val = rlang::dots_list(...)) rlang::inject(ard_regression(x = x, tidy_fun = tidy_fun, !!!args)) |> - dplyr::filter(!.data$stat_name %in% stats_to_remove) + dplyr::filter(!.data$stat_name %in% stats_to_remove) |> + dplyr::select(-(cards::all_ard_variables("levels") & dplyr::where(\(x) all(is.na(x))))) } diff --git a/R/construction_helpers.R b/R/construction_helpers.R index ae5873532..47e220cc2 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"), reference_pkg = "cardx")) +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("withr", "lme4", "broom.helpers"), reference_pkg = "cardx")) #' construct_model( #' x = mtcars, #' formula = am ~ mpg + (1 | vs), diff --git a/man/construction_helpers.Rd b/man/construction_helpers.Rd index 82d5439a3..3264af7f3 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"), 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"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} construct_model( x = mtcars, formula = am ~ mpg + (1 | vs), diff --git a/tests/testthat/_snaps/construction_helpers.md b/tests/testthat/_snaps/construction_helpers.md index e354d9b82..d904c5939 100644 --- a/tests/testthat/_snaps/construction_helpers.md +++ b/tests/testthat/_snaps/construction_helpers.md @@ -5,11 +5,11 @@ mtcars, `M P G` = mpg), formula = reformulate2(c("M P G", "cyl"), response = "hp"), method = "lm"))), stat_name %in% c("term", "estimate", "p.value")) Output - variable variable_level context stat_name stat_label stat fmt_fn - 1 M P G regression term term `M P G` NULL - 2 M P G regression estimate Coefficient -2.774769 1 - 3 M P G regression p.value p-value 0.2125285 1 - 4 cyl regression term term cyl NULL - 5 cyl regression estimate Coefficient 23.97863 1 - 6 cyl regression p.value p-value 0.002814958 1 + variable context stat_name stat_label stat fmt_fn + 1 M P G regression term term `M P G` NULL + 2 M P G regression estimate Coefficient -2.774769 1 + 3 M P G regression p.value p-value 0.2125285 1 + 4 cyl regression term term cyl NULL + 5 cyl regression estimate Coefficient 23.97863 1 + 6 cyl regression p.value p-value 0.002814958 1 diff --git a/tests/testthat/test-ard_regression.R b/tests/testthat/test-ard_regression.R index 6fec0806e..7b834e764 100644 --- a/tests/testthat/test-ard_regression.R +++ b/tests/testthat/test-ard_regression.R @@ -20,3 +20,7 @@ test_that("ard_regression() works", { "Treatment Arm" ) }) + +test_that("ard_regression() does not produce `variable_level` column where not applicable", { + expect_true(!"variable_level" %in% names(lm(mpg ~ hp, mtcars) |> ard_regression())) +}) diff --git a/tests/testthat/test-ard_regression_basic.R b/tests/testthat/test-ard_regression_basic.R index 93932b563..487426348 100644 --- a/tests/testthat/test-ard_regression_basic.R +++ b/tests/testthat/test-ard_regression_basic.R @@ -9,3 +9,7 @@ test_that("ard_regression_basic() works", { expect_snapshot(as.data.frame(ard) |> dplyr::select(-fmt_fn)) }) + +test_that("ard_regression_basic() does not produce `variable_level` column where not applicable", { + expect_true(!"variable_level" %in% names(lm(mpg ~ hp, mtcars) |> ard_regression_basic())) +}) diff --git a/tests/testthat/test-construction_helpers.R b/tests/testthat/test-construction_helpers.R index c8ed0fb2e..0ff715752 100644 --- a/tests/testthat/test-construction_helpers.R +++ b/tests/testthat/test-construction_helpers.R @@ -1,4 +1,4 @@ -skip_if_not(is_pkg_installed(c("withr", "survey"), reference_pkg = "cardx")) +skip_if_not(is_pkg_installed(c("broom.helpers", "withr", "survey"), reference_pkg = "cardx")) test_that("construct_model() works", { expect_snapshot( From 3ef9132d3c0456d9811776ee1e074f6705afbb31 Mon Sep 17 00:00:00 2001 From: ddsjoberg Date: Thu, 25 Apr 2024 15:21:37 +0000 Subject: [PATCH 3/3] [skip actions] Bump version to 0.1.0.9027 --- DESCRIPTION | 2 +- NEWS.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b2513dca0..6ab961ebb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: cardx Title: Extra Analysis Results Data Utilities -Version: 0.1.0.9026 +Version: 0.1.0.9027 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 3d3bbea01..8464b2800 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# cardx 0.1.0.9026 +# cardx 0.1.0.9027 ### Breaking Changes