Skip to content

Commit

Permalink
Update awkward by/strata phrasing (#358)
Browse files Browse the repository at this point in the history
**What changes are proposed in this pull request?**

* Update phrasing for `by` and `strata` arguments (#325 )

Provide more detail here as needed.

Went with the phrasing I suggested in #325, let me know what you think -
happy to brainstorm a little more if it's still not what we're after

closes #325 



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

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] Code coverage is suitable for any new functions/features
(generally, 100% coverage for new code): `devtools::test_coverage()`
- [x] Request a reviewer

Reviewer Checklist (if item does not apply, mark is as complete)

- [ ] If a bug was fixed, a unit test was added.
- [ ] Run `pkgdown::build_site()`. Check the R console for errors, and
review the rendered website.
- [ ] 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 "`# cards (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
jtalboys authored Nov 19, 2024
1 parent 6ea9b21 commit 5e3bb1f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/ard_categorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
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
Expand Up @@ -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")
Expand Down
10 changes: 6 additions & 4 deletions tests/testthat/test-tidy_ard_column_order.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
)
})

0 comments on commit 5e3bb1f

Please sign in to comment.