From b622a580412750cebdb072d599c35ab1348a2965 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Wed, 9 Oct 2024 07:29:08 -0700 Subject: [PATCH] Error handling/messaging update --- R/tbl_cross.R | 2 +- tests/testthat/_snaps/tbl_cross.md | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/R/tbl_cross.R b/R/tbl_cross.R index dacb84f38..d5f1dcd1a 100644 --- a/R/tbl_cross.R +++ b/R/tbl_cross.R @@ -73,7 +73,7 @@ tbl_cross <- function(data, # check inputs --------------------------------------------------------------- check_not_missing(data) - if (!missing(row) + !missing(col) == 1L) { + if (sum(!missing(row), !missing(col)) == 1L) { cli::cli_abort( "Specify both {.arg row} and {.arg col} arguments or neither.", call = get_cli_abort_call() diff --git a/tests/testthat/_snaps/tbl_cross.md b/tests/testthat/_snaps/tbl_cross.md index 0958ececb..d22d52aa9 100644 --- a/tests/testthat/_snaps/tbl_cross.md +++ b/tests/testthat/_snaps/tbl_cross.md @@ -79,9 +79,7 @@ tbl_cross(trial, col = trt) Condition Error in `tbl_cross()`: - ! Error processing `type` argument. - ! i In argument: `all_of(row)`. Caused by error in `all_of()`: ! Can't subset elements that don't exist. x Element `trt` doesn't exist. - i Select among columns "..total.." + ! Specify both `row` and `col` arguments or neither. ---