Skip to content

Commit

Permalink
Merge branch '126-ard_survfit_diff' of https://github.com/insightseng…
Browse files Browse the repository at this point in the history
…ineering/cardx into 126-ard_survfit_diff
  • Loading branch information
ddsjoberg committed Apr 26, 2024
2 parents f16c3d5 + 96fef12 commit 7d7af8e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cardx
Title: Extra Analysis Results Data Utilities
Version: 0.1.0.9025
Version: 0.1.0.9027
Authors@R: c(
person("Daniel", "Sjoberg", , "[email protected]", role = c("aut", "cre")),
person("Abinaya", "Yogasekaram", , "[email protected]", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cardx 0.1.0.9025
# cardx 0.1.0.9027

### Breaking Changes

Expand Down
1 change: 1 addition & 0 deletions R/ard_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion R/ard_regression_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
}
2 changes: 1 addition & 1 deletion R/construction_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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),
Expand Down
2 changes: 1 addition & 1 deletion man/construction_helpers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/testthat/_snaps/construction_helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <NA> regression term term `M P G` NULL
2 M P G <NA> regression estimate Coefficient -2.774769 1
3 M P G <NA> regression p.value p-value 0.2125285 1
4 cyl <NA> regression term term cyl NULL
5 cyl <NA> regression estimate Coefficient 23.97863 1
6 cyl <NA> 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

4 changes: 4 additions & 0 deletions tests/testthat/test-ard_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
})
4 changes: 4 additions & 0 deletions tests/testthat/test-ard_regression_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
})
2 changes: 1 addition & 1 deletion tests/testthat/test-construction_helpers.R
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit 7d7af8e

Please sign in to comment.