From 90f2c230d70e15d129f0adc82ee024f2ac9eb41b Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:28:04 -0400 Subject: [PATCH] Add `@examplesIf` to internal examples where applicable (#120) **What changes are proposed in this pull request?** * Added `@examplesIf` to applicable internal function examples. (#118, @edelarua) Closes #118 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [x] **All** GitHub Action workflows pass with a :white_check_mark: - [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 :white_check_mark: - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge" or "Rebase and merge". --- R/ard_aod_wald_test.R | 2 -- R/ard_effectsize_cohens_d.R | 2 +- R/ard_effectsize_hedges_g.R | 2 +- R/ard_stats_mcnemar_test.R | 2 +- R/ard_stats_mood_test.R | 2 +- R/ard_stats_t_test.R | 2 +- R/ard_stats_wilcox_test.R | 2 +- R/ard_survival_survfit.R | 6 +++--- R/proportion_ci.R | 1 + man/dot-format_cohens_d_results.Rd | 2 ++ man/dot-format_hedges_g_results.Rd | 2 ++ man/dot-format_mcnemartest_results.Rd | 3 ++- man/dot-format_moodtest_results.Rd | 2 ++ man/dot-format_survfit_results.Rd | 3 ++- man/dot-format_ttest_results.Rd | 2 ++ man/dot-format_wilcoxtest_results.Rd | 3 ++- man/dot-process_survfit_probs.Rd | 3 ++- man/dot-process_survfit_time.Rd | 3 ++- 18 files changed, 28 insertions(+), 16 deletions(-) diff --git a/R/ard_aod_wald_test.R b/R/ard_aod_wald_test.R index 6e068c82c..ec87532ab 100644 --- a/R/ard_aod_wald_test.R +++ b/R/ard_aod_wald_test.R @@ -104,12 +104,10 @@ ard_aod_wald_test <- function(x, ...) { #' Extract data from wald.test object #' -#' #' @param wald_test (`data.frame`)\cr wald test object object from `aod::wald.test()` #' #' @return a data frame containing the wald test results. #' @keywords internal - .extract_wald_results <- function(wald_test) { df <- wald_test$result$chi2[("df")] statistic <- wald_test$result$chi2[("chi2")] diff --git a/R/ard_effectsize_cohens_d.R b/R/ard_effectsize_cohens_d.R index 32c9f2f48..a0c298d93 100644 --- a/R/ard_effectsize_cohens_d.R +++ b/R/ard_effectsize_cohens_d.R @@ -159,7 +159,7 @@ ard_effectsize_paired_cohens_d <- function(data, by, variables, id, ...) { #' #' @return ARD data frame #' @keywords internal -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx")) #' cardx:::.format_cohens_d_results( #' by = "ARM", #' variable = "AGE", diff --git a/R/ard_effectsize_hedges_g.R b/R/ard_effectsize_hedges_g.R index aa849de88..8b5b9da6f 100644 --- a/R/ard_effectsize_hedges_g.R +++ b/R/ard_effectsize_hedges_g.R @@ -151,7 +151,7 @@ ard_effectsize_paired_hedges_g <- function(data, by, variables, id, ...) { #' #' @return ARD data frame #' @keywords internal -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx")) #' cardx:::.format_hedges_g_results( #' by = "ARM", #' variable = "AGE", diff --git a/R/ard_stats_mcnemar_test.R b/R/ard_stats_mcnemar_test.R index 07de733c0..4a928d561 100644 --- a/R/ard_stats_mcnemar_test.R +++ b/R/ard_stats_mcnemar_test.R @@ -71,7 +71,7 @@ ard_stats_mcnemar_test <- function(data, by, variables, ...) { #' #' @return ARD data frame #' -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) #' cardx:::.format_mcnemartest_results( #' by = "ARM", #' variable = "AGE", diff --git a/R/ard_stats_mood_test.R b/R/ard_stats_mood_test.R index 9473fac4e..8882cb067 100644 --- a/R/ard_stats_mood_test.R +++ b/R/ard_stats_mood_test.R @@ -73,7 +73,7 @@ ard_stats_mood_test <- function(data, by, variables, ...) { #' #' @return ARD data frame #' @keywords internal -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) #' cardx:::.format_moodtest_results( #' by = "SEX", #' variable = "AGE", diff --git a/R/ard_stats_t_test.R b/R/ard_stats_t_test.R index 6758fc5e6..d00e05fa9 100644 --- a/R/ard_stats_t_test.R +++ b/R/ard_stats_t_test.R @@ -141,7 +141,7 @@ ard_stats_paired_t_test <- function(data, by, variables, id, ...) { #' #' @return ARD data frame #' @keywords internal -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) #' cardx:::.format_ttest_results( #' by = "ARM", #' variable = "AGE", diff --git a/R/ard_stats_wilcox_test.R b/R/ard_stats_wilcox_test.R index e4a1048e4..adff590f9 100644 --- a/R/ard_stats_wilcox_test.R +++ b/R/ard_stats_wilcox_test.R @@ -148,7 +148,7 @@ ard_stats_paired_wilcox_test <- function(data, by, variables, id, ...) { #' #' @return ARD data frame #' -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx")) #' # Pre-processing ADSL to have grouping factor (ARM here) with 2 levels #' ADSL <- cards::ADSL |> #' dplyr::filter(ARM %in% c("Placebo", "Xanomeline High Dose")) |> diff --git a/R/ard_survival_survfit.R b/R/ard_survival_survfit.R index 1022119a7..eee2764a8 100644 --- a/R/ard_survival_survfit.R +++ b/R/ard_survival_survfit.R @@ -113,7 +113,7 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { #' #' @return a `tibble` #' -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("survival", "broom"), reference_pkg = "cardx")) #' survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE) |> #' cardx:::.process_survfit_time(times = c(60, 180), type = "risk") #' @@ -221,7 +221,7 @@ ard_survival_survfit <- function(x, times = NULL, probs = NULL, type = NULL) { #' #' @return a `tibble` #' -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "survival", reference_pkg = "cardx")) #' survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE) |> #' cardx:::.process_survfit_probs(probs = c(0.25, 0.75)) #' @@ -281,7 +281,7 @@ extract_multi_strata <- function(x, df_stat) { #' #' @return an ARD data frame of class 'card' #' -#' @examples +#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("survival", "broom"), reference_pkg = "cardx")) #' cardx:::.format_survfit_results( #' broom::tidy(survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE)) #' ) diff --git a/R/proportion_ci.R b/R/proportion_ci.R index 7c4dc069a..34aef53d2 100644 --- a/R/proportion_ci.R +++ b/R/proportion_ci.R @@ -375,6 +375,7 @@ proportion_ci_strat_wilson <- function(x, #' @seealso [proportion_ci_strat_wilson()] #' #' @keywords internal +#' #' @examples #' strata_data <- table(data.frame( #' "f1" = sample(c(TRUE, FALSE), 100, TRUE), diff --git a/man/dot-format_cohens_d_results.Rd b/man/dot-format_cohens_d_results.Rd index 87de50e57..20edfa95e 100644 --- a/man/dot-format_cohens_d_results.Rd +++ b/man/dot-format_cohens_d_results.Rd @@ -28,6 +28,7 @@ ARD data frame Convert Cohen's D Test to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_cohens_d_results( by = "ARM", variable = "AGE", @@ -38,5 +39,6 @@ cardx:::.format_cohens_d_results( parameters::standardize_names(style = "broom") ) ) +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_hedges_g_results.Rd b/man/dot-format_hedges_g_results.Rd index 3d119c5ca..d22e5b762 100644 --- a/man/dot-format_hedges_g_results.Rd +++ b/man/dot-format_hedges_g_results.Rd @@ -28,6 +28,7 @@ ARD data frame Convert Hedge's G Test to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("effectsize", "parameters"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_hedges_g_results( by = "ARM", variable = "AGE", @@ -38,5 +39,6 @@ cardx:::.format_hedges_g_results( parameters::standardize_names(style = "broom") ) ) +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_mcnemartest_results.Rd b/man/dot-format_mcnemartest_results.Rd index 5d6725c69..a373a3f6b 100644 --- a/man/dot-format_mcnemartest_results.Rd +++ b/man/dot-format_mcnemartest_results.Rd @@ -24,6 +24,7 @@ ARD data frame Convert McNemar's test to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_mcnemartest_results( by = "ARM", variable = "AGE", @@ -33,6 +34,6 @@ cardx:::.format_mcnemartest_results( broom::tidy() ) ) - +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_moodtest_results.Rd b/man/dot-format_moodtest_results.Rd index dbc9a11b8..a3be12b12 100644 --- a/man/dot-format_moodtest_results.Rd +++ b/man/dot-format_moodtest_results.Rd @@ -24,6 +24,7 @@ ARD data frame Convert mood test results to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_moodtest_results( by = "SEX", variable = "AGE", @@ -33,5 +34,6 @@ cardx:::.format_moodtest_results( broom::tidy() ) ) +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_survfit_results.Rd b/man/dot-format_survfit_results.Rd index 824e876ac..0e52d8fe4 100644 --- a/man/dot-format_survfit_results.Rd +++ b/man/dot-format_survfit_results.Rd @@ -13,9 +13,10 @@ an ARD data frame of class 'card' Convert Tidied Survival Fit to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("survival", "broom"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_survfit_results( broom::tidy(survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE)) ) - +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_ttest_results.Rd b/man/dot-format_ttest_results.Rd index b00306f68..5896cc6d5 100644 --- a/man/dot-format_ttest_results.Rd +++ b/man/dot-format_ttest_results.Rd @@ -27,6 +27,7 @@ ARD data frame Convert t-test to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} cardx:::.format_ttest_results( by = "ARM", variable = "AGE", @@ -37,5 +38,6 @@ cardx:::.format_ttest_results( broom::tidy() ) ) +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-format_wilcoxtest_results.Rd b/man/dot-format_wilcoxtest_results.Rd index 083893241..ad4cbd2fe 100644 --- a/man/dot-format_wilcoxtest_results.Rd +++ b/man/dot-format_wilcoxtest_results.Rd @@ -26,6 +26,7 @@ ARD data frame Convert Wilcoxon test to ARD } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # Pre-processing ADSL to have grouping factor (ARM here) with 2 levels ADSL <- cards::ADSL |> dplyr::filter(ARM \%in\% c("Placebo", "Xanomeline High Dose")) |> @@ -41,6 +42,6 @@ cardx:::.format_wilcoxtest_results( broom::tidy() ) ) - +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-process_survfit_probs.Rd b/man/dot-process_survfit_probs.Rd index dc1f588e4..036f9039f 100644 --- a/man/dot-process_survfit_probs.Rd +++ b/man/dot-process_survfit_probs.Rd @@ -20,8 +20,9 @@ a \code{tibble} Process Survival Fit For Quantile Estimates } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "survival", reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE) |> cardx:::.process_survfit_probs(probs = c(0.25, 0.75)) - +\dontshow{\}) # examplesIf} } \keyword{internal} diff --git a/man/dot-process_survfit_time.Rd b/man/dot-process_survfit_time.Rd index 7f1c673a8..c6f9bee25 100644 --- a/man/dot-process_survfit_time.Rd +++ b/man/dot-process_survfit_time.Rd @@ -30,8 +30,9 @@ a \code{tibble} Process Survival Fit For Time Estimates } \examples{ +\dontshow{if (do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = c("survival", "broom"), reference_pkg = "cardx"))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} survival::survfit(survival::Surv(AVAL, CNSR) ~ TRTA, cards::ADTTE) |> cardx:::.process_survfit_time(times = c(60, 180), type = "risk") - +\dontshow{\}) # examplesIf} } \keyword{internal}