Skip to content

Commit

Permalink
comparise sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
teunbrand committed Sep 20, 2024
1 parent 0b823b4 commit 661539a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/scale-.R
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ ScaleContinuous <- ggproto("ScaleContinuous", Scale,
labels <- self$labels
}

if (length(labels) != length(breaks)) {
if (!identical(size0(labels), size0(breaks))) {
cli::cli_abort(
"{.arg breaks} and {.arg labels} have different lengths.",
call = self$call
Expand Down
10 changes: 10 additions & 0 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,16 @@ as_unordered_factor <- function(x) {
x
}

size0 <- function(x) {
if (obj_is_vector(x)) {
vec_size(x)
} else if (is.vector(x)) {
length(x)
} else {
NULL
}
}

warn_dots_used <- function(env = caller_env(), call = caller_env()) {
check_dots_used(
env = env, call = call,
Expand Down

0 comments on commit 661539a

Please sign in to comment.