Skip to content

Commit

Permalink
update context after renaming ard_* functions (#123)
Browse files Browse the repository at this point in the history
**What changes are proposed in this pull request?**
update context after renaming `ard_*()` functions

closes #117 


--------------------------------------------------------------------------------

Pre-review Checklist (if item does not apply, mark is as complete)
- [x] **All** GitHub Action workflows pass with a ✅
- [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] 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 ✅
- [ ] Approve Pull Request
- [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge".
  • Loading branch information
ayogasekaram authored Apr 16, 2024
1 parent ecd78dd commit ca91444
Show file tree
Hide file tree
Showing 30 changed files with 177 additions and 172 deletions.
2 changes: 1 addition & 1 deletion R/ard_car_vif.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ard_car_vif <- function(x, ...) {
values_to = "stat"
) |>
dplyr::mutate(
context = "vif",
context = "car_vif",
stat_label = ifelse(
.data$stat_name == "aGVIF",
"Adjusted GVIF",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_effectsize_cohens_d.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ard_effectsize_paired_cohens_d <- function(data, by, variables, id, ...) {
fun_args_to_record = c("mu", "paired", "pooled_sd", "alternative"),
formals = formals(asNamespace("effectsize")[["cohens_d"]]),
passed_args = c(list(paired = paired), dots_list(...)),
lst_ard_columns = list(group1 = by, variable = variable, context = "cohens_d")
lst_ard_columns = list(group1 = by, variable = variable, context = "effectsize_cohens_d")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_effectsize_hedges_g.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, 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 = "hedges_g")
lst_ard_columns = list(group1 = by, variable = variable, context = "effectsize_hedges_g")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_smd_smd.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ard_smd_smd <- function(data, by, variables, ...) {
formals = formals(smd::smd)["gref"],
# removing the `std.error` ARGUMENT (not the result)
passed_args = dots_list(...) |> utils::modifyList(list(std.error = NULL)),
lst_ard_columns = list(group1 = by, variable = variable, context = "smd")
lst_ard_columns = list(group1 = by, variable = variable, context = "smd_smd")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_aov.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ard_stats_aov <- function(formula, data, ...) {
.data$stat_name %in% "meansq" ~ "Mean of Sum of Squares",
TRUE ~ .data$stat_name
),
context = "aov",
context = "stats_aov",
warning = aov["warning"],
error = aov["error"]
) |>
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_chisq_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ard_stats_chisq_test <- function(data, by, variables, ...) {
c("correct", "p", "rescale.p", "simulate.p.value", "B"),
formals = formals(stats::chisq.test),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "chisqtest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_chisq_test")
) |>
dplyr::mutate(
.after = "stat_name",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_fisher_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ard_stats_fisher_test <- function(data, by, variables, ...) {
),
formals = formals(stats::fisher.test),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "fishertest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_fisher_test")
) |>
dplyr::mutate(
.after = "stat_name",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_kruskal_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ard_stats_kruskal_test <- function(data, by, variables) {
broom::tidy()
),
tidy_result_names = c("statistic", "p.value", "parameter", "method"),
lst_ard_columns = list(group1 = by, variable = variable, context = "kruskaltest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_kruskal_test")
) |>
dplyr::mutate(
.after = "stat_name",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_mcnemar_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ard_stats_mcnemar_test <- function(data, by, variables, ...) {
fun_args_to_record = c("correct"),
formals = formals(asNamespace("stats")[["mcnemar.test"]]),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "mcnemartest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_mcnemar_test")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_mood_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ard_stats_mood_test <- function(data, by, variables, ...) {
tidy_result_names = c("statistic", "p.value", "method", "alternative"),
formals = formals(asNamespace("stats")[["mood.test.default"]]),
passed_args = c(dots_list(...)),
lst_ard_columns = list(group1 = by, variable = variable, context = "moodtest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_mood_test")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_oneway_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ard_stats_oneway_test <- function(formula, data, ...) {
c("var.equal"),
formals = formals(stats::oneway.test),
passed_args = dots_list(...),
lst_ard_columns = list(context = "oneway.test")
lst_ard_columns = list(context = "stats_oneway_test")
) |>
dplyr::mutate(
.after = "stat_name",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_prop_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ard_stats_prop_test <- function(data, by, variables, ...) {
fun_args_to_record = c("p", "conf.level", "correct"),
formals = formals(stats::prop.test),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "proptest")
lst_ard_columns = list(group1 = by, variable = variable, context = "stats_prop_test")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_t_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ ard_stats_paired_t_test <- function(data, by, variables, id, ...) {
fun_args_to_record = c("mu", "paired", "var.equal", "conf.level"),
formals = formals(asNamespace("stats")[["t.test.default"]]),
passed_args = c(list(paired = paired), dots_list(...)),
lst_ard_columns = list(variable = variable, context = "ttest")
lst_ard_columns = list(variable = variable, context = "stats_t_test")
)

if (!is_empty(by)) {
Expand Down
2 changes: 1 addition & 1 deletion R/ard_stats_wilcox_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ ard_stats_paired_wilcox_test <- function(data, by, variables, id, ...) {
),
formals = formals(asNamespace("stats")[["wilcox.test.default"]]),
passed_args = c(list(paired = paired), dots_list(...)),
lst_ard_columns = list(variable = variable, context = "wilcoxtest")
lst_ard_columns = list(variable = variable, context = "stats_wilcox_test")
)

if (!is_empty(by)) {
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svychisq.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ard_survey_svychisq <- function(data, by, variables, statistic = "F", ...) {
),
tidy_result_names = c("statistic", "p.value", "ndf", "ddf", "method"),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "svychisq")
lst_ard_columns = list(group1 = by, variable = variable, context = "survey_svychisq")
) |>
dplyr::mutate(
.after = "stat_name",
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svycontinuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ ard_survey_svycontinuous <- function(data, variables, by = NULL,

# add class and return ARD object --------------------------------------------
df_stats |>
dplyr::mutate(context = "continuous") |>
dplyr::mutate(context = "survey_svycontinuous") |>
cards::tidy_ard_column_order() %>%
{structure(., class = c("card", class(.)))} # styler: off
}
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svyranktest.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ard_survey_svyranktest <- function(data, by, variables, test, ...) {
"method", "alternative"
),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "svyranktest")
lst_ard_columns = list(group1 = by, variable = variable, context = "survey_svyranktest")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survey_svyttest.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ard_survey_svyttest <- function(data, by, variables, conf.level = 0.95, ...) {
"conf.level", "method", "alternative"
),
passed_args = dots_list(...),
lst_ard_columns = list(group1 = by, variable = variable, context = "svyttest")
lst_ard_columns = list(group1 = by, variable = variable, context = "survey_svyttest")
)

# add the stat label ---------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion R/ard_survival_survfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) {
) %>%
dplyr::bind_rows() %>%
`rownames<-`(NULL) %>%
dplyr::mutate(context = "survival") %>%
dplyr::mutate(context = "survival_survfit") %>%
dplyr::as_tibble()

if (length(x$n) == 1) df_stat <- df_stat %>% dplyr::select(-"strata")
Expand Down
24 changes: 12 additions & 12 deletions tests/testthat/_snaps/ard_car_vif.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
as.data.frame(ard_car_vif(lm(AGE ~ ARM + SEX, data = cards::ADSL)))
Output
variable context stat_name stat_label stat fmt_fn warning error
1 ARM vif GVIF GVIF 1.015675 1 NULL NULL
2 ARM vif df df 2.000000 1 NULL NULL
3 ARM vif aGVIF Adjusted GVIF 1.003896 1 NULL NULL
4 SEX vif GVIF GVIF 1.015675 1 NULL NULL
5 SEX vif df df 1.000000 1 NULL NULL
6 SEX vif aGVIF Adjusted GVIF 1.007807 1 NULL NULL
1 ARM car_vif GVIF GVIF 1.015675 1 NULL NULL
2 ARM car_vif df df 2.000000 1 NULL NULL
3 ARM car_vif aGVIF Adjusted GVIF 1.003896 1 NULL NULL
4 SEX car_vif GVIF GVIF 1.015675 1 NULL NULL
5 SEX car_vif df df 1.000000 1 NULL NULL
6 SEX car_vif aGVIF Adjusted GVIF 1.007807 1 NULL NULL

---

Code
as.data.frame(ard_car_vif(lm(AGE ~ BMIBL + EDUCLVL, data = cards::ADSL)))
Output
variable context stat_name stat_label stat fmt_fn warning error
1 BMIBL vif VIF VIF 1.010522 1 NULL NULL
2 EDUCLVL vif VIF VIF 1.010522 1 NULL NULL
1 BMIBL car_vif VIF VIF 1.010522 1 NULL NULL
2 EDUCLVL car_vif VIF VIF 1.010522 1 NULL NULL

# ard_car_vif() appropriate errors are given for model with only 1 term

Code
as.data.frame(ard_car_vif(lm(AGE ~ ARM, data = cards::ADSL)))
Output
variable context stat_name stat_label stat fmt_fn warning
1 ARM vif VIF VIF NULL NULL NULL
2 ARM vif GVIF GVIF NULL NULL NULL
3 ARM vif aGVIF Adjusted GVIF NULL NULL NULL
4 ARM vif df df NULL NULL NULL
1 ARM car_vif VIF VIF NULL NULL NULL
2 ARM car_vif GVIF GVIF NULL NULL NULL
3 ARM car_vif aGVIF Adjusted GVIF NULL NULL NULL
4 ARM car_vif df df NULL NULL NULL
error
1 model contains fewer than 2 terms
2 model contains fewer than 2 terms
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/_snaps/ard_effectsize_cohens_d.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"Xanomeline High Dose")), by = ARM, variables = c(BMIBL, HEIGHTBL)), c(1:3,
5:6)), variable), n = 3))
Output
group1 variable context stat_label stat
1 ARM BMIBL cohens_d Effect Size Estimate -0.436653
2 ARM BMIBL cohens_d CI Confidence Level 0.95
3 ARM BMIBL cohens_d CI Lower Bound -0.740282
4 ARM HEIGHTBL cohens_d Effect Size Estimate -0.299056
5 ARM HEIGHTBL cohens_d CI Confidence Level 0.95
6 ARM HEIGHTBL cohens_d CI Lower Bound -0.600975
group1 variable context stat_label stat
1 ARM BMIBL effectsize_cohens_d Effect Size Estimate -0.436653
2 ARM BMIBL effectsize_cohens_d CI Confidence Level 0.95
3 ARM BMIBL effectsize_cohens_d CI Lower Bound -0.740282
4 ARM HEIGHTBL effectsize_cohens_d Effect Size Estimate -0.299056
5 ARM HEIGHTBL effectsize_cohens_d CI Confidence Level 0.95
6 ARM HEIGHTBL effectsize_cohens_d CI Lower Bound -0.600975

# ard_effectsize_paired_cohens_d() works

Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/_snaps/ard_effectsize_hedges_g.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"Xanomeline High Dose")), by = ARM, variables = c(BMIBL, HEIGHTBL)), c(1:3,
5:6)), variable), n = 3))
Output
group1 variable context stat_label stat
1 ARM BMIBL hedges_g Effect Size Estimate -0.4347006
2 ARM BMIBL hedges_g CI Confidence Level 0.95
3 ARM BMIBL hedges_g CI Lower Bound -0.7369717
4 ARM HEIGHTBL hedges_g Effect Size Estimate -0.2977188
5 ARM HEIGHTBL hedges_g CI Confidence Level 0.95
6 ARM HEIGHTBL hedges_g CI Lower Bound -0.5982873
group1 variable context stat_label stat
1 ARM BMIBL effectsize_hedges_g Effect Size Estimate -0.4347006
2 ARM BMIBL effectsize_hedges_g CI Confidence Level 0.95
3 ARM BMIBL effectsize_hedges_g CI Lower Bound -0.7369717
4 ARM HEIGHTBL effectsize_hedges_g Effect Size Estimate -0.2977188
5 ARM HEIGHTBL effectsize_hedges_g CI Confidence Level 0.95
6 ARM HEIGHTBL effectsize_hedges_g CI Lower Bound -0.5982873

# ard_effectsize_paired_hedges_g() works

Expand Down
22 changes: 11 additions & 11 deletions tests/testthat/_snaps/ard_stats_aov.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Code
as.data.frame(ard_stats_aov(AGE ~ ARM + SEX, data = cards::ADSL))
Output
variable context stat_name stat_label stat warning error
1 ARM aov sumsq Sum of Squares 71.38574 NULL NULL
2 ARM aov df Degrees of Freedom 2 NULL NULL
3 ARM aov meansq Mean of Sum of Squares 35.69287 NULL NULL
4 ARM aov statistic Statistic 0.5235002 NULL NULL
5 ARM aov p.value p-value 0.5930912 NULL NULL
6 SEX aov sumsq Sum of Squares 87.40947 NULL NULL
7 SEX aov df Degrees of Freedom 1 NULL NULL
8 SEX aov meansq Mean of Sum of Squares 87.40947 NULL NULL
9 SEX aov statistic Statistic 1.282017 NULL NULL
10 SEX aov p.value p-value 0.2586091 NULL NULL
variable context stat_name stat_label stat warning error
1 ARM stats_aov sumsq Sum of Squares 71.38574 NULL NULL
2 ARM stats_aov df Degrees of Freedom 2 NULL NULL
3 ARM stats_aov meansq Mean of Sum of Squares 35.69287 NULL NULL
4 ARM stats_aov statistic Statistic 0.5235002 NULL NULL
5 ARM stats_aov p.value p-value 0.5930912 NULL NULL
6 SEX stats_aov sumsq Sum of Squares 87.40947 NULL NULL
7 SEX stats_aov df Degrees of Freedom 1 NULL NULL
8 SEX stats_aov meansq Mean of Sum of Squares 87.40947 NULL NULL
9 SEX stats_aov statistic Statistic 1.282017 NULL NULL
10 SEX stats_aov p.value p-value 0.2586091 NULL NULL

18 changes: 9 additions & 9 deletions tests/testthat/_snaps/ard_stats_chisq_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
by = "ARM", variables = "AGEGR1"), ard_stats_chisq_test(data = adsl_sub, by = "SEX",
variables = "AGEGR1"))))
Output
ARM SEX variable context stat_name stat
1 Overall ARM <NA> AGEGR1 chisqtest statistic 5.079442e+00
2 Overall ARM <NA> AGEGR1 chisqtest p.value 7.888842e-02
3 Overall ARM <NA> AGEGR1 chisqtest parameter 2.000000e+00
4 Overall ARM <NA> AGEGR1 chisqtest B 2.000000e+03
5 <NA> Overall SEX AGEGR1 chisqtest statistic 1.039442e+00
6 <NA> Overall SEX AGEGR1 chisqtest p.value 5.946864e-01
7 <NA> Overall SEX AGEGR1 chisqtest parameter 2.000000e+00
8 <NA> Overall SEX AGEGR1 chisqtest B 2.000000e+03
ARM SEX variable context stat_name stat
1 Overall ARM <NA> AGEGR1 stats_chisq_test statistic 5.079442e+00
2 Overall ARM <NA> AGEGR1 stats_chisq_test p.value 7.888842e-02
3 Overall ARM <NA> AGEGR1 stats_chisq_test parameter 2.000000e+00
4 Overall ARM <NA> AGEGR1 stats_chisq_test B 2.000000e+03
5 <NA> Overall SEX AGEGR1 stats_chisq_test statistic 1.039442e+00
6 <NA> Overall SEX AGEGR1 stats_chisq_test p.value 5.946864e-01
7 <NA> Overall SEX AGEGR1 stats_chisq_test parameter 2.000000e+00
8 <NA> Overall SEX AGEGR1 stats_chisq_test B 2.000000e+03

25 changes: 15 additions & 10 deletions tests/testthat/_snaps/ard_stats_kruskal_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
Code
as.data.frame(ard_stats_kruskal_test(cards::ADSL, by = "ARM", variables = "AGE"))
Output
group1 variable context stat_name stat_label
1 ARM AGE kruskaltest statistic Kruskal-Wallis chi-squared Statistic
2 ARM AGE kruskaltest p.value p-value
3 ARM AGE kruskaltest parameter Degrees of Freedom
4 ARM AGE kruskaltest method method
stat fmt_fn warning error
1 1.63473 1 NULL NULL
2 0.4415937 1 NULL NULL
3 2 1 NULL NULL
4 Kruskal-Wallis rank sum test NULL NULL NULL
group1 variable context stat_name
1 ARM AGE stats_kruskal_test statistic
2 ARM AGE stats_kruskal_test p.value
3 ARM AGE stats_kruskal_test parameter
4 ARM AGE stats_kruskal_test method
stat_label stat fmt_fn
1 Kruskal-Wallis chi-squared Statistic 1.63473 1
2 p-value 0.4415937 1
3 Degrees of Freedom 2 1
4 method Kruskal-Wallis rank sum test NULL
warning error
1 NULL NULL
2 NULL NULL
3 NULL NULL
4 NULL NULL

10 changes: 5 additions & 5 deletions tests/testthat/_snaps/ard_stats_mood_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Code
as.data.frame(ard_stats_mood_test(cards::ADSL, by = SEX, variable = AGE))
Output
group1 variable context stat_name stat_label
1 SEX AGE moodtest statistic Z-Statistic
2 SEX AGE moodtest p.value p-value
3 SEX AGE moodtest method method
4 SEX AGE moodtest alternative Alternative Hypothesis
group1 variable context stat_name stat_label
1 SEX AGE stats_mood_test statistic Z-Statistic
2 SEX AGE stats_mood_test p.value p-value
3 SEX AGE stats_mood_test method method
4 SEX AGE stats_mood_test alternative Alternative Hypothesis
stat fmt_fn warning error
1 0.1292194 1 NULL NULL
2 0.8971841 1 NULL NULL
Expand Down
Loading

0 comments on commit ca91444

Please sign in to comment.