Skip to content

Commit fcd9c4b

Browse files
committed
replace is.discrete() with is_discrete()
1 parent 7658827 commit fcd9c4b

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

R/grouping.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ add_group <- function(data) {
1212
if (empty(data)) return(data)
1313

1414
if (is.null(data[["group"]])) {
15-
disc <- vapply(data, is.discrete, logical(1))
15+
disc <- vapply(data, is_discrete, logical(1))
1616
disc[names(disc) %in% c("label", "PANEL")] <- FALSE
1717

1818
if (any(disc)) {

R/guide-legend.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ set_key_size <- function(key, linewidth = NULL, size = NULL, default = NULL) {
647647
keep_key_data <- function(key, data, aes, show) {
648648
# First, can we exclude based on anything else than actually checking the
649649
# data that we should include or drop the key?
650-
if (!is.discrete(key$.value)) {
650+
if (!is_discrete(key$.value)) {
651651
return(TRUE)
652652
}
653653
if (is_named(show)) {

R/quick-plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE,
121121
geom[geom == "auto"] <- "qq"
122122
} else if (missing(y)) {
123123
x <- eval_tidy(mapping$x, data, caller_env)
124-
if (is.discrete(x)) {
124+
if (is_discrete(x)) {
125125
geom[geom == "auto"] <- "bar"
126126
} else {
127127
geom[geom == "auto"] <- "histogram"

R/scale-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ discrete_scale <- function(aesthetics, scale_name = deprecated(), palette, name
228228
labels <- allow_lambda(labels)
229229
minor_breaks <- allow_lambda(minor_breaks)
230230

231-
if (!is.function(limits) && (length(limits) > 0) && !is.discrete(limits)) {
231+
if (!is.function(limits) && (length(limits) > 0) && !is_discrete(limits)) {
232232
cli::cli_warn(c(
233233
"Continuous limits supplied to discrete scale.",
234234
"i" = "Did you mean {.code limits = factor(...)} or {.fn scale_*_continuous}?"
@@ -965,7 +965,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
965965
return()
966966
}
967967
# Intercept error here to give examples and mention scale in call
968-
if (!is.discrete(x)) {
968+
if (!is_discrete(x)) {
969969
# These assumptions only hold for standard DiscreteRange class, so
970970
# we skip the error if another range class is used
971971
if (inherits(self$range, "DiscreteRange")) {

R/scale-discrete-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
119119
continuous_limits = NULL,
120120

121121
train = function(self, x) {
122-
if (is.discrete(x)) {
122+
if (is_discrete(x)) {
123123
self$range$train(x, drop = self$drop, na.rm = !self$na.translate)
124124
} else {
125125
self$range_c$train(x)
@@ -156,7 +156,7 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
156156
if (inherits(x, "AsIs")) {
157157
return(x)
158158
}
159-
if (is.discrete(x)) {
159+
if (is_discrete(x)) {
160160
values <- self$palette(length(limits))
161161
if (!is.numeric(values)) {
162162
cli::cli_abort(

R/scale-expansion.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ expand_limits_discrete_trans <- function(limits, expand = expansion(0, 0),
228228
range_continuous = NULL) {
229229
discrete_limits <- NULL
230230
if (length(limits) > 0) {
231-
if (is.discrete(limits)) {
231+
if (is_discrete(limits)) {
232232
discrete_limits <- c(1, length(limits)) # for backward compatibility
233233
} else {
234234
discrete_limits <- range(limits)

R/utilities.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,15 @@ empty <- function(df) {
287287
is.null(df) || nrow(df) == 0 || ncol(df) == 0 || is_waiver(df)
288288
}
289289

290-
is.discrete <- function(x) {
290+
is_discrete <- function(x) {
291291
is.factor(x) || is.character(x) || is.logical(x)
292292
}
293293

294+
is.discrete <- function(x) {
295+
deprecate_warn0("4.0.0", "is.discrete()", "is_discrete()")
296+
is_discrete(x)
297+
}
298+
294299
check_nondata_cols <- function(data, mapping, problem = NULL, hint = NULL) {
295300
# We define "data" as atomic types or lists, not functions or otherwise.
296301
# The `inherits(x, "Vector")` check is for checking S4 classes from Bioconductor

0 commit comments

Comments
 (0)