Skip to content

Commit

Permalink
removing missing values before calculating values to avoid note about…
Browse files Browse the repository at this point in the history
… NA values being dropped
  • Loading branch information
ddsjoberg committed May 6, 2024
1 parent 5ffd9d6 commit cea214d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 11 additions & 2 deletions R/ard_effectsize_cohens_d.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
),
Expand Down Expand Up @@ -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") |>
Expand Down
14 changes: 12 additions & 2 deletions R/ard_effectsize_hedges_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit cea214d

Please sign in to comment.