Skip to content

Commit

Permalink
renaming hedgesg to hedges_g
Browse files Browse the repository at this point in the history
  • Loading branch information
ddsjoberg committed Mar 2, 2024
1 parent 43cf600 commit 3461e6c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export(any_of)
export(ard_chisqtest)
export(ard_cohens_d)
export(ard_fishertest)
export(ard_hedgesg)
export(ard_hedges_g)
export(ard_kruskaltest)
export(ard_mcnemartest)
export(ard_moodtest)
export(ard_paired_cohens_d)
export(ard_paired_hedgesg)
export(ard_paired_hedges_g)
export(ard_paired_ttest)
export(ard_paired_wilcoxtest)
export(ard_proportion_ci)
Expand Down
28 changes: 14 additions & 14 deletions R/ard_hedgesg.R → R/ard_hedges_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
#' @param ... arguments passed to `effectsize::hedges_g(...)`
#'
#' @return ARD data frame
#' @name ard_hedgesg
#' @name ard_hedges_g
#'
#' @details
#' For the `ard_hedgesg()` function, the data is expected to be one row per subject.
#' For the `ard_hedges_g()` function, the data is expected to be one row per subject.
#' The data is passed as `effectsize::hedges_g(data[[variable]]~data[[by]], data, paired = FALSE, ...)`.
#'
#' For the `ard_paired_hedgesg()` function, the data is expected to be one row
#' For the `ard_paired_hedges_g()` function, the data is expected to be one row
#' per subject per by level. Before the effect size is calculated, the data are
#' reshaped to a wide format to be one row per subject.
#' The data are then passed as
Expand All @@ -30,7 +30,7 @@
#' @examples
#' cards::ADSL |>
#' dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
#' ard_hedgesg(by = ARM, variable = AGE)
#' ard_hedges_g(by = ARM, variable = AGE)
#'
#' # constructing a paired data set,
#' # where patients receive both treatments
Expand All @@ -40,12 +40,12 @@
#' dplyr::arrange(USUBJID, ARM) |>
#' dplyr::group_by(USUBJID) |>
#' dplyr::filter(dplyr::n() > 1) |>
#' ard_paired_hedgesg(by = ARM, variable = AGE, id = USUBJID)
#' ard_paired_hedges_g(by = ARM, variable = AGE, id = USUBJID)
NULL

#' @rdname ard_hedgesg
#' @rdname ard_hedges_g
#' @export
ard_hedgesg <- function(data, by, variable, ...) {
ard_hedges_g <- function(data, by, variable, ...) {
# check installed packages ---------------------------------------------------
cards::check_pkg_installed("effectsize", reference_pkg = "cardx")
cards::check_pkg_installed("parameters", reference_pkg = "cardx")
Expand All @@ -59,7 +59,7 @@ ard_hedgesg <- function(data, by, variable, ...) {
check_scalar(variable)

# build ARD ------------------------------------------------------------------
.format_hedgesg_results(
.format_hedges_g_results(
by = by,
variable = variable,
lst_tidy =
Expand All @@ -72,9 +72,9 @@ ard_hedgesg <- function(data, by, variable, ...) {
)
}

#' @rdname ard_hedgesg
#' @rdname ard_hedges_g
#' @export
ard_paired_hedgesg <- function(data, by, variable, id, ...) {
ard_paired_hedges_g <- function(data, by, variable, id, ...) {
# check installed packages ---------------------------------------------------
cards::check_pkg_installed("effectsize", reference_pkg = "cardx")
cards::check_pkg_installed("parameters", reference_pkg = "cardx")
Expand All @@ -92,7 +92,7 @@ ard_paired_hedgesg <- function(data, by, variable, id, ...) {
check_scalar(id)

# build ARD ------------------------------------------------------------------
.format_hedgesg_results(
.format_hedges_g_results(
by = by,
variable = variable,
lst_tidy =
Expand All @@ -119,7 +119,7 @@ ard_paired_hedgesg <- function(data, by, variable, id, ...) {
#' @return ARD data frame
#' @keywords internal
#' @examples
#' cardx:::.format_hedgesg_results(
#' cardx:::.format_hedges_g_results(
#' by = "ARM",
#' variable = "AGE",
#' paired = FALSE,
Expand All @@ -129,7 +129,7 @@ ard_paired_hedgesg <- function(data, by, variable, id, ...) {
#' parameters::standardize_names(style = "broom")
#' )
#' )
.format_hedgesg_results <- function(by, variable, lst_tidy, paired, ...) {
.format_hedges_g_results <- function(by, variable, lst_tidy, paired, ...) {
# build ARD ------------------------------------------------------------------
ret <-
cards::tidy_as_ard(
Expand All @@ -140,7 +140,7 @@ ard_paired_hedgesg <- function(data, by, variable, id, ...) {
fun_args_to_record = c("mu", "paired", "pooled_sd", "alternative"),
formals = formals(asNamespace("effectsize")[["hedges_g"]]),
passed_args = c(list(paired = paired), dots_list(...)),
lst_ard_columns = list(group1 = by, variable = variable, context = "hedgesg")
lst_ard_columns = list(group1 = by, variable = variable, context = "hedges_g")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ reference:
- ard_chisqtest
- ard_cohens_d
- ard_fishertest
- ard_hedgesg
- ard_hedges_g
- ard_kruskaltest
- ard_moodtest
- ard_mcnemartest
Expand Down
20 changes: 10 additions & 10 deletions man/ard_hedgesg.Rd → man/ard_hedges_g.Rd

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

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

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ard_hedgesg() works
# ard_hedges_g() works

Code
as.data.frame(dplyr::select(ard_hedgesg(cards::ADSL, by = ARM, variable = AGE),
as.data.frame(dplyr::select(ard_hedges_g(cards::ADSL, by = ARM, variable = AGE),
c("variable", "stat_name", "error")))
Output
variable stat_name error
Expand All @@ -14,10 +14,10 @@
7 AGE pooled_sd Grouping variable y must have exactly 2 levels.
8 AGE alternative Grouping variable y must have exactly 2 levels.

# ard_paired_hedgesg() works
# ard_paired_hedges_g() works

Code
as.data.frame(dplyr::select(ard_paired_hedgesg(dplyr::mutate(ADSL_paired, ARM = ifelse(
as.data.frame(dplyr::select(ard_paired_hedges_g(dplyr::mutate(ADSL_paired, ARM = ifelse(
dplyr::row_number() == 1L, "3rd ARM", ARM)), by = ARM, variable = AGE, id = USUBJID),
c("variable", "stat_name", "error")))
Output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
skip_if_not(cards::is_pkg_installed("effectsize", reference_pkg = "cardx"))
skip_if_not(cards::is_pkg_installed("parameters", reference_pkg = "cardx"))

test_that("ard_hedgesg() works", {
test_that("ard_hedges_g() works", {
expect_error(
ard_hedgesg <-
ard_hedges_g <-
cards::ADSL |>
dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
ard_hedgesg(by = ARM, variable = AGE),
ard_hedges_g(by = ARM, variable = AGE),
NA
)

expect_equal(
ard_hedgesg |>
ard_hedges_g |>
cards::get_ard_statistics(stat_name %in% c("estimate", "conf.low", "conf.high")),
effectsize::hedges_g(
AGE ~ ARM,
Expand All @@ -25,13 +25,13 @@ test_that("ard_hedgesg() works", {
# errors are properly handled
expect_snapshot(
cards::ADSL |>
ard_hedgesg(by = ARM, variable = AGE) |>
ard_hedges_g(by = ARM, variable = AGE) |>
dplyr::select(c("variable", "stat_name", "error")) |>
as.data.frame()
)
})

test_that("ard_paired_hedgesg() works", {
test_that("ard_paired_hedges_g() works", {
ADSL_paired <-
cards::ADSL[c("ARM", "AGE")] |>
dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |>
Expand All @@ -40,14 +40,14 @@ test_that("ard_paired_hedgesg() works", {
dplyr::filter(dplyr::n() > 1)

expect_error(
ard_paired_hedgesg <-
ard_paired_hedges_g <-
ADSL_paired |>
ard_paired_hedgesg(by = ARM, variable = AGE, id = USUBJID),
ard_paired_hedges_g(by = ARM, variable = AGE, id = USUBJID),
NA
)

expect_equal(
ard_paired_hedgesg |>
ard_paired_hedges_g |>
cards::get_ard_statistics(stat_name %in% c("estimate", "conf.low", "conf.high")),
with(
data =
Expand All @@ -74,7 +74,7 @@ test_that("ard_paired_hedgesg() works", {
dplyr::mutate(
ARM = ifelse(dplyr::row_number() == 1L, "3rd ARM", ARM)
) |>
ard_paired_hedgesg(by = ARM, variable = AGE, id = USUBJID) |>
ard_paired_hedges_g(by = ARM, variable = AGE, id = USUBJID) |>
dplyr::select(c("variable", "stat_name", "error")) |>
as.data.frame()
)
Expand Down

0 comments on commit 3461e6c

Please sign in to comment.