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

Improve error message + tweak function signature respect error_arg for allow_rename = FALSE #358

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
use standard type checking
olivroy committed Oct 23, 2024
commit a7610113790456d37883f86063fabc26eccf5093
10 changes: 3 additions & 7 deletions R/eval-select.R
Original file line number Diff line number Diff line change
@@ -209,15 +209,13 @@ eval_select_impl <- function(x,
)

if (length(include) > 0) {
if (!is.character(include)) {
cli::cli_abort("{.arg include} must be a character vector.", call = error_call)
}
check_character(include, call = error_call)

missing <- setdiff(include, names)
if (length(missing) > 0) {
cli::cli_abort(c(
"{.arg include} must only include variables found in {.arg data}.",
i = "Unknown variables: {.and {missing}}"
i = "Unknown variables: {.var {missing}}"
), call = error_call)
}

@@ -228,9 +226,7 @@ eval_select_impl <- function(x,
}

if (length(exclude) > 0) {
if (!is.character(exclude)) {
cli::cli_abort("{.arg include} must be a character vector.", call = error_call)
}
check_character(exclude, call = error_call)

to_exclude <- vctrs::vec_match(intersect(exclude, names), names)
out <- out[!out %in% to_exclude]
5 changes: 1 addition & 4 deletions R/helpers-misc.R
Original file line number Diff line number Diff line change
@@ -61,10 +61,7 @@ everything <- function(vars = NULL) {
#' @export
#' @param offset Set it to `n` to select the nth var from the end.
last_col <- function(offset = 0L, vars = NULL) {
if (!is_integerish(offset, n = 1)) {
not <- obj_type_friendly(offset)
cli::cli_abort("{.arg offset} must be a single integer, not {not}.")
}
check_number_whole(offset)

vars <- vars %||% peek_vars(fn = "last_col")
n <- length(vars)
Loading