Skip to content

Commit

Permalink
Merged origin/main into svy-ard_categorical
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Jun 13, 2024
2 parents af2057d + 18c9c80 commit ada6843
Show file tree
Hide file tree
Showing 11 changed files with 231 additions and 92 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
# - {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-1'}
# - {os: ubuntu-latest, r: 'oldrel-2'}
# - {os: ubuntu-latest, r: 'oldrel-3'}
# - {os: ubuntu-latest, r: 'oldrel-4'}
Expand All @@ -54,6 +54,13 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

# https://github.com/lme4/lme4/issues/763
- name: Install Matrix/lme4
shell: Rscript {0}
run: |
utils::install.packages("Matrix", repos = c(CRAN = "https://cloud.r-project.org"))
utils::install.packages("lme4", repos = c(CRAN = "https://cloud.r-project.org"))
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
6 changes: 3 additions & 3 deletions 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.9051
Version: 0.1.0.9054
Authors@R: c(
person("Daniel", "Sjoberg", , "[email protected]", role = c("aut", "cre")),
person("Abinaya", "Yogasekaram", , "[email protected]", role = "aut"),
Expand Down Expand Up @@ -30,11 +30,11 @@ Suggests:
broom.helpers (>= 1.15.0),
broom.mixed (>= 0.2.9),
car (>= 3.0-11),
effectsize (>= 0.6.0),
effectsize (>= 0.8.8),
emmeans (>= 1.7.3),
geepack (>= 1.3.2),
ggsurvfit (>= 1.1.0),
lme4 (>= 1.1-31),
lme4 (>= 1.1-35.1),
parameters (>= 0.20.2),
smd (>= 0.6.6),
spelling,
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.9051
# cardx 0.1.0.9054

### Breaking Changes

Expand Down
28 changes: 9 additions & 19 deletions R/ard_effectsize_hedges_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' The data are then passed as
#' `effectsize::hedges_g(x = data_wide[[<by level 1>]], y = data_wide[[<by level 2>]], paired = TRUE, ...)`.
#'
#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters", "withr"), reference_pkg = "cardx"))
#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx"))
#' cards::ADSL |>
#' dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
#' ard_effectsize_hedges_g(by = ARM, variables = AGE)
Expand All @@ -52,7 +52,7 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...)
set_cli_abort_call()

# check installed packages ---------------------------------------------------
check_pkg_installed(c("effectsize", "parameters", "withr"), reference_pkg = "cardx")
check_pkg_installed(c("effectsize", "parameters"), reference_pkg = "cardx")

# check/process inputs -------------------------------------------------------
check_not_missing(data)
Expand All @@ -77,19 +77,12 @@ ard_effectsize_hedges_g <- function(data, by, variables, conf.level = 0.95, ...)
variable = variable,
lst_tidy =
cards::eval_capture_conditions(
# Need to eval in NAMESAPCE DUE TO BUG IN effectsize v0.8.7.
# Can remove this later along with requirements for withr to be installed.
# Will also need to remove `hedges_g` from globalVariables()
withr::with_namespace(
package = "effectsize",
code =
hedges_g(
reformulate2(by, response = variable),
data = data |> tidyr::drop_na(all_of(c(by, variable))),
paired = FALSE,
ci = conf.level,
...
)
effectsize::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")
Expand Down Expand Up @@ -143,10 +136,7 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, conf.level =
.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",
code = hedges_g(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...)
) |>
effectsize::hedges_g(x = data_wide[["by1"]], y = data_wide[["by2"]], paired = TRUE, ci = conf.level, ...) |>
parameters::standardize_names(style = "broom") |>
dplyr::mutate(method = "Paired Hedge's G")
}),
Expand Down
2 changes: 1 addition & 1 deletion R/cardx-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
## usethis namespace: end
NULL

utils::globalVariables(c(".", "hedges_g"))
utils::globalVariables(c("."))
Loading

0 comments on commit ada6843

Please sign in to comment.