Skip to content

Commit 7410496

Browse files
authored
Merge branch 'main' into remove_lookups
Signed-off-by: Lluís Revilla <185338939+llrs-roche@users.noreply.github.com>
2 parents 38952d5 + e84ebf5 commit 7410496

14 files changed

+129
-120
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: cardx
22
Title: Extra Analysis Results Data Utilities
3-
Version: 0.2.2.9020
3+
Version: 0.2.2.9024
44
Authors@R: c(
55
person("Daniel D.", "Sjoberg", , "danield.sjoberg@gmail.com", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-0862-2018")),
@@ -20,7 +20,7 @@ BugReports: https://github.com/insightsengineering/cardx/issues
2020
Depends:
2121
R (>= 4.1)
2222
Imports:
23-
cards (>= 0.4.0.9028),
23+
cards (>= 0.5.0),
2424
cli (>= 3.6.1),
2525
dplyr (>= 1.1.2),
2626
glue (>= 1.6.2),

NEWS.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
# cardx 0.2.2.9020
1+
# cardx 0.2.2.9024
22

3-
* Added `as_cards_fun()` to `ard_categorical_ci()` so when there is an error, the user gets an ARD with the expected ARD structure. (#262)
3+
## New Features and Updates
4+
5+
* Added function `ard_categorical_max()` to calculate categorical occurrence rates by maximum level per unique ID. (#240)
6+
7+
## Other Updates
48

59
* Little `n` is now returned with the results of the `proportion_ci_*()` functions, which then flows into the results of `ard_proportion_ci()`. (#256)
610

11+
* Added `as_cards_fun()` to `ard_categorical_ci()` so when there is an error, the user gets an ARD with the expected ARD structure. (#262)
12+
713
* Update in `ard_categorical.survey.design()` for factor variables that are all missing. These variables can now be tabulated, where previously this resulted in an error.
814

915
* Update in `ard_missing.survey.design()` where we can now tabulate the missing rate of design variables, such as the weights.
1016

17+
## Bug Fixes
18+
1119
* Fixed a bug in `ard_survival_survfit()` causing an error when "=" character is present in stratification variable level labels. (#252)
1220

13-
* Added function `ard_categorical_max()` to calculate categorical occurrence rates by maximum level per unique ID. (#240)
21+
* Bug fix in `ard_categorical_ci(denominator='cell')` when missing values were present in the `by` variable.
1422

1523
# cardx 0.2.2
1624

R/ard_categorical_ci.R

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
#' @inheritParams cards::ard_categorical
66
#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr
77
#' columns to include in summaries. Columns must be class `<logical>`
8-
#' or `<numeric>` values coded as `c(0, 1)`.
8+
#' or `<numeric>` values coded as `c(0,1)`.
99
#' @param by ([`tidy-select`][dplyr::dplyr_tidy_select])\cr
1010
#' columns to stratify calculations by.
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
1414
#' `cards::ard_categorical(denominator)`.
15-
#' @param conf.level (`numeric`)\cr
16-
#' a scalar in `(0, 1)` indicating the confidence level.
15+
#' @param conf.level (scalar `numeric`)\cr
16+
#' a scalar in `(0,1)` indicating the confidence level.
1717
#' Default is `0.95`
1818
#' @param method (`string`)\cr
1919
#' string indicating the type of confidence interval to calculate.
@@ -241,7 +241,7 @@ ard_categorical_ci.data.frame <- function(data,
241241
}
242242

243243
.levels_for_row <- function(data, by) {
244-
cards::nest_for_ard(data = data, by = by, include_data = FALSE) |>
244+
suppressMessages(cards::nest_for_ard(data = data, by = by, include_data = FALSE)) |>
245245
dplyr::select(cards::all_ard_groups(types = "levels")) |>
246246
map(unlist) |>
247247
reduce(.f = \(.x, .y) paste0(.x, .y)) |>
@@ -318,7 +318,7 @@ ard_categorical_ci.data.frame <- function(data,
318318
}
319319

320320

321-
df_grouping_cols <- cards::nest_for_ard(data, by = by, include_data = FALSE)
321+
df_grouping_cols <- suppressMessages(cards::nest_for_ard(data, by = by, include_data = FALSE))
322322
levels <- .levels_for_row(data = data, by = by)
323323

324324
suppressMessages(
@@ -413,19 +413,27 @@ ard_categorical_ci.data.frame <- function(data,
413413
dplyr::mutate(
414414
...a_name_anyone_would_ever_pick... =
415415
dplyr::coalesce(.data$...a_name_anyone_would_ever_pick..., paste(levels, collapse = ""))
416-
) |>
416+
)
417+
418+
# make dummy vector missing if any of the other variables are missing
419+
dummy_data[["...a_name_anyone_would_ever_pick..."]][apply(is.na(dummy_data[c(variable, by, strata)]), MARGIN = 1, FUN = any)] <- NA
420+
421+
# finish processing dummy data
422+
dummy_data <- dummy_data |>
417423
dplyr::select(-any_of(c(variable, by))) %>%
418-
{
419-
dplyr::bind_cols(
420-
.,
421-
map(
422-
levels,
423-
\(level) (.[["...a_name_anyone_would_ever_pick..."]] == level)
424-
) |>
425-
stats::setNames(paste0("level_", levels)) |>
426-
dplyr::as_tibble()
427-
)
428-
} |>
424+
# styler: off
425+
{dplyr::bind_cols(
426+
.,
427+
map(
428+
levels,
429+
\(level) {
430+
(.[["...a_name_anyone_would_ever_pick..."]] == level)
431+
}
432+
) |>
433+
stats::setNames(paste0("level_", levels)) |>
434+
dplyr::as_tibble()
435+
)} |>
436+
# styler: on
429437
dplyr::select(-"...a_name_anyone_would_ever_pick...")
430438

431439
prop_ci_fun <-

R/proportion_ci.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' Functions to calculate different proportion confidence intervals for use in `ard_proportion()`.
44
#'
55
#' @inheritParams ard_categorical_ci
6-
#' @param x vector of a binary values, i.e. a logical vector, or numeric with values `c(0, 1)`
6+
#' @param x (binary `numeric`/`logical`)\cr
7+
#' vector of a binary values, i.e. a logical vector, or numeric with values `c(0, 1)`
78
#' @return Confidence interval of a proportion.
89
#'
910
#' @name proportion_ci
@@ -238,12 +239,12 @@ proportion_ci_jeffreys <- function(x, conf.level = 0.95) {
238239
#'
239240
#'
240241
#' @param strata (`factor`)\cr variable with one level per stratum and same length as `x`.
241-
#' @param weights (`numeric` or `NULL`)\cr weights for each level of the strata. If `NULL`, they are
242+
#' @param weights (`numeric`)\cr weights for each level of the strata. If `NULL`, they are
242243
#' estimated using the iterative algorithm that
243244
#' minimizes the weighted squared length of the confidence interval.
244-
#' @param max.iterations (`count`)\cr maximum number of iterations for the iterative procedure used
245+
#' @param max.iterations (positive `integer`)\cr maximum number of iterations for the iterative procedure used
245246
#' to find estimates of optimal weights.
246-
#' @param correct (`flag`)\cr include the continuity correction. For further information, see for example
247+
#' @param correct (scalar `logical`)\cr include the continuity correction. For further information, see for example
247248
#' [stats::prop.test()].
248249
#'
249250
#' @examples

cran-comments.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66

77
## R CMD check results
88

9-
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
9+
(I added my middle initial to my name to match my other packages on CRAN.)
10+
11+
New maintainer:
12+
Daniel D. Sjoberg <danield.sjoberg@gmail.com>
13+
Old maintainer(s):
14+
Daniel Sjoberg <danield.sjoberg@gmail.com>
15+
16+
0 errors ✔ | 0 warnings ✔ | 1 note ✖
1017

1118
## revdepcheck results
1219

1320
We checked 4 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package.
1421

15-
* We saw 1 new problem in gtsummary, and it is slated to be released next week (I am the maintainer).
22+
* We saw 0 new problems
1623
* We failed to check 0 packages
1724

1825
## Additional Comments

man/ard_categorical_ci.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ard_categorical_ci.survey.design.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dot-strata_normal_quantile.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/dot-update_weights_strat_wilson.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/proportion_ci.Rd

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)