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. ---