From 0076c51939cfa09186102205528c7df26d2d8cf1 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 11:41:36 +0200 Subject: [PATCH 1/3] fix ggplot2 checks --- R/scale-continuous.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/scale-continuous.R b/R/scale-continuous.R index a0bc6051..bc75a0c5 100644 --- a/R/scale-continuous.R +++ b/R/scale-continuous.R @@ -47,7 +47,7 @@ train_continuous <- function(new, existing = NULL, call = caller_env()) { } new <- try_fetch( - range(new, na.rm = TRUE), + suppressWarnings(range(new, na.rm = TRUE, finite = TRUE)), error = function(cnd) new ) From f708ba7090030e807b790a2b3d6e29a00aeee463 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 12:38:17 +0200 Subject: [PATCH 2/3] extra paranoia for `breaks_pretty()` --- R/breaks.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/breaks.R b/R/breaks.R index e5e378c9..c3e67493 100644 --- a/R/breaks.R +++ b/R/breaks.R @@ -135,7 +135,7 @@ breaks_pretty <- function(n = 5, ...) { force_all(n, ...) n_default <- n function(x, n = n_default) { - if (zero_range(as.numeric(x))) { + if (length(x) > 0 && zero_range(range(as.numeric(x), na.rm = TRUE))) { return(x[1]) } breaks <- pretty(x, n, ...) From 53e8844a8ddcd6d09932ff6b6263917b4bb48d77 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 23 Apr 2025 12:59:52 +0200 Subject: [PATCH 3/3] extra paranoia for strings with level attribute --- R/scale-discrete.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/scale-discrete.R b/R/scale-discrete.R index 2063efa7..d45b338a 100644 --- a/R/scale-discrete.R +++ b/R/scale-discrete.R @@ -100,7 +100,7 @@ clevels <- function(x, drop = FALSE, na.rm = FALSE) { if (is.null(x)) { character() } else if (!is.null(levels(x))) { - if (drop) x <- droplevels(x) + if (drop && !is.character(x)) x <- droplevels(x) values <- levels(x) if (na.rm) {