Skip to content

Commit

Permalink
Updating error message in rename_ard_columns() (#341)
Browse files Browse the repository at this point in the history
**What changes are proposed in this pull request?**
Error message update for `rename_ard_columns(unlist)` to indicate the
function to call to assist with NULL values.

<img width="978" alt="image"
src="https://github.com/user-attachments/assets/2fa0d2f6-be50-4223-8c86-78bfa3eae226">


**Reference GitHub issue associated with pull request.** _e.g., 'closes
#<issue number>'_
closes #332


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

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.
- [ ] Code coverage is suitable for any new functions/features
(generally, 100% coverage for new code): `devtools::test_coverage()`
- [ ] 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
ddsjoberg authored Sep 27, 2024
1 parent 2290a30 commit 920ab61
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/replace_null_statistic.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Replace NULL Statistics with Specified Value
#'
#' When a statistical summary function errors, the `"statistic"` column will be
#' When a statistical summary function errors, the `"stat"` column will be
#' `NULL`. It is, however, sometimes useful to replace these values with a
#' non-`NULL` value, e.g. `NA`.
#'
Expand Down
3 changes: 2 additions & 1 deletion R/shift_ard_columns.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ rename_ard_columns <- function(x, columns = c(all_ard_groups(), all_ard_variable
if (length(unlisted) != length(x[[unlist_var]])) {
cli::cli_abort(
c("Cannot unlist column {.val {unlist_var}}. The unlisted result is not the same length as the original.",
"i" = "This often occurs when the column contains {.code NULL} values."
"i" = "This often occurs when the column contains {.code NULL} values.",
if (unlist_var == "stat") c("*" = "Run {.fun cards::replace_null_statistic} to replace {.code NULL} values with {.val {NA}}.") # styler: off
),
call = get_cli_abort_call()
)
Expand Down
2 changes: 1 addition & 1 deletion man/replace_null_statistic.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/_snaps/rename_ard_columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
Error in `rename_ard_columns()`:
! Cannot unlist column "stat". The unlisted result is not the same length as the original.
i This often occurs when the column contains `NULL` values.
* Run `cards::replace_null_statistic()` to replace `NULL` values with NA.

0 comments on commit 920ab61

Please sign in to comment.