Skip to content

Commit 649b9b8

Browse files
authored
Core function renames (#315)
**What changes are proposed in this pull request?** * The following functions have been renamed. - `ard_continuous()` to `ard_summary()` - `ard_categorical()` to `ard_tabulate()` - `ard_dichotomous()` to `ard_tabulate_value()` - `ard_categorical_max()` to `ard_tabulate_max()` **Reference GitHub issue associated with pull request.** _e.g., 'closes #<issue number>'_ closes #314 -------------------------------------------------------------------------------- Pre-review Checklist (if item does not apply, mark is as complete) - [ ] **All** GitHub Action workflows pass with a ✅ - [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` - [ ] If a bug was fixed, a unit test was added. - [ ] If a new `ard_*()` function was added, it passes the ARD structural checks from `cards::check_ard_structure()`. - [ ] If a new `ard_*()` function was added, `set_cli_abort_call()` has been set. - [ ] If a new `ard_*()` function was added and it depends on another package (such as, `broom`), `is_pkg_installed("broom")` has been set in the function call and the following added to the roxygen comments: `@examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "broom""))` - [ ] 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".
1 parent c60f10f commit 649b9b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+618
-495
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ BugReports: https://github.com/insightsengineering/cardx/issues
2222
Depends:
2323
R (>= 4.2)
2424
Imports:
25-
cards (>= 0.6.1.9008),
25+
cards (>= 0.6.1.9016),
2626
cli (>= 3.6.1),
2727
dplyr (>= 1.1.2),
2828
glue (>= 1.6.2),

NAMESPACE

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ S3method(ard_regression_basic,data.frame)
1515
S3method(ard_regression_basic,default)
1616
S3method(ard_stats_anova,anova)
1717
S3method(ard_stats_anova,data.frame)
18+
S3method(ard_summary,survey.design)
1819
S3method(ard_survival_survfit,data.frame)
1920
S3method(ard_survival_survfit,survfit)
21+
S3method(ard_tabulate,survey.design)
22+
S3method(ard_tabulate_value,survey.design)
2023
S3method(ard_total_n,survey.design)
2124
S3method(construct_model,data.frame)
2225
S3method(construct_model,survey.design)
@@ -28,7 +31,6 @@ export(ard_attributes)
2831
export(ard_car_anova)
2932
export(ard_car_vif)
3033
export(ard_categorical)
31-
export(ard_categorical_abnormal)
3234
export(ard_categorical_ci)
3335
export(ard_categorical_max)
3436
export(ard_continuous)
@@ -62,12 +64,17 @@ export(ard_stats_t_test)
6264
export(ard_stats_t_test_onesample)
6365
export(ard_stats_wilcox_test)
6466
export(ard_stats_wilcox_test_onesample)
67+
export(ard_summary)
6568
export(ard_survey_svychisq)
6669
export(ard_survey_svyranktest)
6770
export(ard_survey_svyttest)
6871
export(ard_survival_survdiff)
6972
export(ard_survival_survfit)
7073
export(ard_survival_survfit_diff)
74+
export(ard_tabulate)
75+
export(ard_tabulate_abnormal)
76+
export(ard_tabulate_max)
77+
export(ard_tabulate_value)
7178
export(ard_total_n)
7279
export(bt)
7380
export(bt_strip)
@@ -95,6 +102,9 @@ importFrom(cards,ard_categorical)
95102
importFrom(cards,ard_continuous)
96103
importFrom(cards,ard_dichotomous)
97104
importFrom(cards,ard_missing)
105+
importFrom(cards,ard_summary)
106+
importFrom(cards,ard_tabulate)
107+
importFrom(cards,ard_tabulate_value)
98108
importFrom(cards,ard_total_n)
99109
importFrom(dplyr,"%>%")
100110
importFrom(dplyr,across)

NEWS.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# cardx 0.2.5.9002
22

3-
* Added function `ard_categorical_abnormal()` to calculate ARDs for abnormality analyses. (#310)
3+
* The following functions have been renamed.
4+
- `ard_continuous()` to `ard_summary()`
5+
- `ard_categorical()` to `ard_tabulate()`
6+
- `ard_dichotomous()` to `ard_tabulate_value()`
7+
- `ard_categorical_max()` to `ard_tabulate_max()`
48

5-
* Adding `strata` argument to `ard_categorical_max()`. (#445, @jtalboys)
9+
* Added function `ard_tabulate_abnormal()` to calculate ARDs for abnormality analyses. (#310)
10+
11+
* Adding `strata` argument to `ard_tabulate_max()`. (#445, @jtalboys)
612

713
* Added function `ard_incidence_rate()` to calculate ARDs for incidence rate estimation. (#234)
814

R/add_total_n.survey.design.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' Returns the total N for a survey object.
44
#' The placeholder variable name returned in the object is `"..ard_total_n.."`
55
#'
6-
#' @inheritParams ard_dichotomous.survey.design
6+
#' @inheritParams ard_tabulate_value.survey.design
77
#' @inheritParams rlang::args_dots_empty
88
#'
99
#' @return an ARD data frame of class 'card'
@@ -22,7 +22,7 @@ ard_total_n.survey.design <- function(data, ...) {
2222
data <- stats::update(data, ..ard_total_n.. = TRUE)
2323

2424
data |>
25-
ard_dichotomous(
25+
ard_tabulate_value(
2626
variables = "..ard_total_n..",
2727
statistic = list(..ard_total_n.. = c("N", "N_unweighted"))
2828
) |>

R/ard_categorical_ci.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' Calculate confidence intervals for proportions.
44
#'
5-
#' @inheritParams cards::ard_categorical
5+
#' @inheritParams cards::ard_tabulate
66
#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr
77
#' columns to include in summaries. Columns must be class `<logical>`
88
#' or `<numeric>` values coded as `c(0,1)`.
@@ -11,7 +11,7 @@
1111
#' @param denominator (`string`)\cr
1212
#' Must be one of `'column'` (default), `'row'`, and `'cell'`, which specifies
1313
#' the direction of the calculation/denominator. Argument is similar to
14-
#' `cards::ard_categorical(denominator)`.
14+
#' `cards::ard_tabulate(denominator)`.
1515
#' @param conf.level (scalar `numeric`)\cr
1616
#' a scalar in `(0,1)` indicating the confidence level.
1717
#' Default is `0.95`

R/ard_categorical_ci.survey.design.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' Confidence intervals for categorical variables calculated via
44
#' [`survey::svyciprop()`].
55
#'
6-
#' @inheritParams ard_continuous.survey.design
6+
#' @inheritParams ard_summary.survey.design
77
#' @inheritParams ard_categorical_ci.data.frame
88
#' @param method (`string`)\cr
99
#' Method passed to `survey::svyciprop(method)`

R/ard_continuous.survey.design.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#' the list element is either a named list or a list of formulas defining the
2424
#' statistic labels, e.g. `everything() ~ list(mean = "Mean", sd = "SD")` or
2525
#' `everything() ~ list(mean ~ "Mean", sd ~ "SD")`.
26-
#' @inheritParams ard_categorical.survey.design
26+
#' @inheritParams ard_tabulate.survey.design
2727
#' @inheritParams rlang::args_dots_empty
2828
#'
2929
#' @section statistic argument:
@@ -42,26 +42,26 @@
4242
#' data(api, package = "survey")
4343
#' dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
4444
#'
45-
#' ard_continuous(
45+
#' ard_summary(
4646
#' data = dclus1,
4747
#' variables = api00,
4848
#' by = stype
4949
#' )
50-
ard_continuous.survey.design <- function(data, variables, by = NULL,
51-
statistic = everything() ~ c("median", "p25", "p75"),
52-
fmt_fun = NULL,
53-
stat_label = NULL,
54-
fmt_fn = deprecated(),
55-
...) {
50+
ard_summary.survey.design <- function(data, variables, by = NULL,
51+
statistic = everything() ~ c("median", "p25", "p75"),
52+
fmt_fun = NULL,
53+
stat_label = NULL,
54+
fmt_fn = deprecated(),
55+
...) {
5656
set_cli_abort_call()
5757
check_dots_empty()
5858

5959
# deprecated args ------------------------------------------------------------
6060
if (lifecycle::is_present(fmt_fn)) {
6161
lifecycle::deprecate_soft(
6262
when = "0.2.5",
63-
what = "ard_continuous(fmt_fn)",
64-
with = "ard_continuous(fmt_fun)"
63+
what = "ard_summary(fmt_fn)",
64+
with = "ard_summary(fmt_fun)"
6565
)
6666
fmt_fun <- fmt_fn
6767
}
@@ -85,7 +85,7 @@ ard_continuous.survey.design <- function(data, variables, by = NULL,
8585
)
8686
cards::fill_formula_selectors(
8787
data$variables[variables],
88-
statistic = formals(asNamespace("cardx")[["ard_continuous.survey.design"]])[["statistic"]] |> eval()
88+
statistic = formals(asNamespace("cardx")[["ard_summary.survey.design"]])[["statistic"]] |> eval()
8989
)
9090
cards::check_list_elements(
9191
x = statistic,

R/ard_continuous_ci.survey.design.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' Confidence limits are calculated with `survey::svymean()` and `survey::svyquantile()`.
55
#'
66
#'
7-
#' @inheritParams ard_continuous.survey.design
7+
#' @inheritParams ard_summary.survey.design
88
#' @param method (`string`)\cr
99
#' Method for confidence interval calculation.
1010
#' When `"svymean"`, the calculation is computed via `survey::svymean()`.

R/ard_incidence_rate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#' confidence interval type for the estimated incidence rate.
3030
#'
3131
#' One of: `normal` (default), `normal-log`, `exact`, or `byar`.
32-
#' @inheritParams cards::ard_continuous
32+
#' @inheritParams cards::ard_summary
3333
#'
3434
#' @return an ARD data frame of class 'card'
3535
#' @export

R/ard_missing.survey.design.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#'
33
#' Compute Analysis Results Data (ARD) for statistics related to data missingness for survey objects
44
#'
5-
#' @inheritParams ard_categorical.survey.design
5+
#' @inheritParams ard_tabulate.survey.design
66
#'
77
#' @return an ARD data frame of class 'card'
88
#' @export
@@ -95,7 +95,7 @@ ard_missing.survey.design <- function(data,
9595

9696
# calculate results ----------------------------------------------------------
9797
result <-
98-
ard_categorical(
98+
ard_tabulate(
9999
data = data,
100100
variables = all_of(paste0("lgl_", variables)),
101101
by = any_of(by),

0 commit comments

Comments
 (0)