Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update awkward by/strata phrasing #358

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/ard_categorical.R
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
#' @param data (`data.frame`)\cr
#' a data frame
#' @param by,strata ([`tidy-select`][dplyr::dplyr_tidy_select])\cr
#' columns to tabulate by/stratify by for tabulation.
#' columns to use for grouping or stratifying the table output.
#' Arguments are similar, but with an important distinction:
#'
#' `by`: results are tabulated by **all combinations** of the columns specified,
10 changes: 7 additions & 3 deletions R/print.R
Original file line number Diff line number Diff line change
@@ -38,9 +38,13 @@ print.card <- function(x, n = NULL, columns = c("auto", "all"), n_col = 6L, ...)
# remove columns -------------------------------------------------------------
if (arg_match(columns) %in% "auto") {
x_print <-
dplyr::select(x_print, all_ard_groups(), all_ard_variables(),
any_of(c("context", "stat_name", "stat_label", "stat", "stat_fmt",
"fmt_fn", "warning", "error")))
dplyr::select(
x_print, all_ard_groups(), all_ard_variables(),
any_of(c(
"context", "stat_name", "stat_label", "stat", "stat_fmt",
"fmt_fn", "warning", "error"
))
)

# remove warning and error columns if nothing to report
if (ncol(x_print) > n_col && "warning" %in% names(x_print) && every(x_print[["warning"]], is.null)) {
2 changes: 1 addition & 1 deletion man/ard_categorical.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/ard_dichotomous.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/dot-calculate_tabulation_statistics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/dot-process_denominator.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions tests/testthat/test-ard_hierarchical.R
Original file line number Diff line number Diff line change
@@ -350,10 +350,12 @@ test_that("ard_hierarchical_count() provides correct results with 10+ groups", {
expect_equal(
dplyr::select(ard, all_ard_groups(), all_ard_variables()) |>
names(),
c('group1', 'group1_level', 'group2', 'group2_level', 'group3', 'group3_level',
'group4', 'group4_level', 'group5', 'group5_level', 'group6', 'group6_level',
'group7', 'group7_level', 'group8', 'group8_level', 'group9', 'group9_level',
'variable', 'variable_level')
c(
"group1", "group1_level", "group2", "group2_level", "group3", "group3_level",
"group4", "group4_level", "group5", "group5_level", "group6", "group6_level",
"group7", "group7_level", "group8", "group8_level", "group9", "group9_level",
"variable", "variable_level"
)
)

expect_equal(ard[["variable"]][[1]], "x10")
10 changes: 6 additions & 4 deletions tests/testthat/test-tidy_ard_column_order.R
Original file line number Diff line number Diff line change
@@ -24,9 +24,11 @@ test_that("tidy_ard_column_order() works", {
) |>
dplyr::select(all_ard_groups(), all_ard_variables()) |>
names(),
c('group1', 'group1_level', 'group2', 'group2_level', 'group3', 'group3_level',
'group4', 'group4_level', 'group5', 'group5_level', 'group6', 'group6_level',
'group7', 'group7_level', 'group8', 'group8_level', 'group9', 'group9_level',
'group10', 'group10_level', 'variable', 'variable_level')
c(
"group1", "group1_level", "group2", "group2_level", "group3", "group3_level",
"group4", "group4_level", "group5", "group5_level", "group6", "group6_level",
"group7", "group7_level", "group8", "group8_level", "group9", "group9_level",
"group10", "group10_level", "variable", "variable_level"
)
)
})