Skip to content

Commit d2cf9db

Browse files
teunbrandthomasp85
andauthored
Bump deprecations (#6138)
* `deprecate_stop()` for everything prior to ggplot2 3.0.0 * stuff before 3.2.0 becomes proper warning * add news bullet * document * use tidy eval idioms to replace old idioms * run revdepcheck * use dynamic deprecation strategy in `fix_bin_params()` * just treat old elements as any other misspelled element * Get more in-your-face about deprecating size in favour of linewidth * bump `qplot()` * Turn `fix_labeller()` into a check function * bump version in bullet --------- Co-authored-by: Thomas Lin Pedersen <[email protected]>
1 parent f21a858 commit d2cf9db

22 files changed

+18648
-23897
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ggplot2 (development version)
22

3+
* Deprecated functions and arguments prior to ggplot2 3.0.0 throw errors instead
4+
of warnings.
5+
* Functions and arguments that were soft-deprecated up to ggplot2 3.4.0 now
6+
throw warnings.
37
* (internal) layer data can be attenuated with parameter attributes
48
(@teunbrand, #3175).
59
* Date scales silently coerce <POSIXct> to <Date> and datetime scales silently

R/aes.R

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ is_position_aes <- function(vars) {
290290
#'
291291
#' @export
292292
aes_ <- function(x, y, ...) {
293-
deprecate_soft0(
293+
deprecate_warn0(
294294
"3.0.0",
295295
"aes_()",
296296
details = "Please use tidy evaluation idioms with `aes()`"
@@ -317,7 +317,7 @@ aes_ <- function(x, y, ...) {
317317
#' @rdname aes_
318318
#' @export
319319
aes_string <- function(x, y, ...) {
320-
deprecate_soft0(
320+
deprecate_warn0(
321321
"3.0.0",
322322
"aes_string()",
323323
details = c(
@@ -374,29 +374,7 @@ aes_all <- function(vars) {
374374
#' @keywords internal
375375
#' @export
376376
aes_auto <- function(data = NULL, ...) {
377-
deprecate_warn0("2.0.0", "aes_auto()")
378-
379-
# detect names of data
380-
if (is.null(data)) {
381-
cli::cli_abort("{.fn aes_auto} requires a {.cls data.frame} or names of data.frame.")
382-
} else if (is.data.frame(data)) {
383-
vars <- names(data)
384-
} else {
385-
vars <- data
386-
}
387-
388-
# automatically detected aes
389-
vars <- intersect(ggplot_global$all_aesthetics, vars)
390-
names(vars) <- vars
391-
aes <- lapply(vars, function(x) parse(text = x)[[1]])
392-
393-
# explicitly defined aes
394-
if (length(match.call()) > 2) {
395-
args <- as.list(match.call()[-1])
396-
aes <- c(aes, args[names(args) != "data"])
397-
}
398-
399-
structure(rename_aes(aes), class = "uneval")
377+
lifecycle::deprecate_stop("2.0.0", "aes_auto()")
400378
}
401379

402380
mapped_aesthetics <- function(x) {

R/annotation-custom.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ GeomCustomAnn <- ggproto("GeomCustomAnn", Geom,
8080
editGrob(grob, vp = vp, name = paste(grob$name, annotation_id()))
8181
},
8282

83-
default_aes = aes_(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
83+
default_aes = aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
8484
)
8585

8686
annotation_id <- local({

R/bin.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,18 +240,24 @@ bin_loc <- function(x, id) {
240240
)
241241
}
242242

243-
fix_bin_params = function(params, fun, version) {
243+
fix_bin_params <- function(params, fun, version) {
244+
245+
if (package_version(version) < "3.0.0") {
246+
deprecate <- lifecycle::deprecate_stop
247+
} else {
248+
deprecate <- deprecate_warn0
249+
}
244250

245251
if (!is.null(params$origin)) {
246252
args <- paste0(fun, c("(origin)", "(boundary)"))
247-
deprecate_warn0(version, args[1], args[2])
248-
params$boudnary <- params$origin
253+
deprecate(version, args[1], args[2])
254+
params$boundary <- params$origin
249255
params$origin <- NULL
250256
}
251257

252258
if (!is.null(params$right)) {
253259
args <- paste0(fun, c("(right)", "(closed)"))
254-
deprecate_warn0(version, args[1], args[2])
260+
deprecate(version, args[1], args[2])
255261
params$closed <- if (isTRUE(params$right)) "right" else "left"
256262
params$right <- NULL
257263
}

R/facet-grid-.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
132132
switch = NULL, drop = TRUE, margins = FALSE,
133133
axes = "margins", axis.labels = "all",
134134
facets = deprecated()) {
135-
# `facets` is deprecated and renamed to `rows`
135+
# `facets` is deprecated
136136
if (lifecycle::is_present(facets)) {
137-
deprecate_warn0("2.2.0", "facet_grid(facets)", "facet_grid(rows)")
138-
rows <- facets
137+
lifecycle::deprecate_stop("2.2.0", "facet_grid(facets)", "facet_grid(rows)")
139138
}
140139

141140
# Should become a warning in a future release
@@ -177,7 +176,7 @@ facet_grid <- function(rows = NULL, cols = NULL, scales = "fixed",
177176
facets_list <- grid_as_facets_list(rows, cols)
178177

179178
# Check for deprecated labellers
180-
labeller <- fix_labeller(labeller)
179+
check_labeller(labeller)
181180

182181
ggproto(NULL, FacetGrid,
183182
shrink = shrink,

R/facet-wrap.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed",
174174
)
175175

176176
# Check for deprecated labellers
177-
labeller <- fix_labeller(labeller)
177+
check_labeller(labeller)
178178

179179
# Flatten all facets dimensions into a single one
180180
facets <- compact_facets(facets)
181181

182182
if (lifecycle::is_present(switch) && !is.null(switch)) {
183-
deprecate_warn0("2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)")
184-
strip.position <- if (switch == "x") "bottom" else "left"
183+
lifecycle::deprecate_stop(
184+
"2.2.0", "facet_wrap(switch)", "facet_wrap(strip.position)"
185+
)
185186
}
186187
strip.position <- arg_match0(strip.position, c("top", "bottom", "left", "right"))
187188

R/fortify-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,6 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
159159
borders <- function(database = "world", regions = ".", fill = NA,
160160
colour = "grey50", xlim = NULL, ylim = NULL, ...) {
161161
df <- map_data(database, regions, xlim = xlim, ylim = ylim)
162-
geom_polygon(aes_(~long, ~lat, group = ~group), data = df,
162+
geom_polygon(aes(.data$long, .data$lat, group = .data$group), data = df,
163163
fill = fill, colour = colour, ..., inherit.aes = FALSE)
164164
}

R/geom-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Geom <- ggproto("Geom",
126126
# Take care of subclasses setting the wrong default when inheriting from
127127
# a geom with rename_size = TRUE
128128
if (self$rename_size && is.null(default_aes$linewidth)) {
129-
deprecate_soft0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere"))
129+
deprecate_warn0("3.4.0", I("Using the `size` aesthetic in this geom"), I("`linewidth` in the `default_aes` field and elsewhere"))
130130
default_aes$linewidth <- default_aes$size
131131
}
132132

@@ -281,7 +281,7 @@ check_aesthetics <- function(x, n) {
281281

282282
fix_linewidth <- function(data, name) {
283283
if (is.null(data$linewidth) && !is.null(data$size)) {
284-
deprecate_soft0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic"))
284+
deprecate_warn0("3.4.0", I(paste0("Using the `size` aesthetic with ", name)), I("the `linewidth` aesthetic"))
285285
data$linewidth <- data$size
286286
}
287287
data

R/geom-spoke.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ geom_spoke <- function(mapping = NULL, data = NULL,
4747
#' @rdname geom_spoke
4848
#' @usage NULL
4949
stat_spoke <- function(...) {
50-
deprecate_warn0("2.0.0", "stat_spoke()", "geom_spoke()")
51-
geom_spoke(...)
50+
lifecycle::deprecate_stop("2.0.0", "stat_spoke()", "geom_spoke()")
5251
}
5352

5453
#' @rdname ggplot2-ggproto

R/labeller.R

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ labeller <- function(..., .rows = NULL, .cols = NULL,
411411
keep.as.numeric = deprecated(), .multi_line = TRUE,
412412
.default = label_value) {
413413
if (lifecycle::is_present(keep.as.numeric)) {
414-
deprecate_warn0("2.0.0", "labeller(keep.as.numeric)")
414+
lifecycle::deprecate_stop("2.0.0", "labeller(keep.as.numeric)")
415415
}
416416
dots <- list2(...)
417417
.default <- as_labeller(.default)
@@ -577,22 +577,18 @@ assemble_strips <- function(grobs, theme, horizontal = TRUE, clip) {
577577
})
578578
}
579579

580-
# Repair old school labeller
581-
fix_labeller <- function(labeller) {
580+
# Reject old school labeller
581+
check_labeller <- function(labeller) {
582+
582583
labeller <- match.fun(labeller)
583584
is_deprecated <- all(c("variable", "value") %in% names(formals(labeller)))
584585

585-
if (is_deprecated) {
586-
deprecate_warn0(
587-
"2.0.0", what = "facet_(labeller)",
588-
details =
589-
"Modern labellers do not take `variable` and `value` arguments anymore."
590-
)
591-
old_labeller <- labeller
592-
labeller <- function(labels) {
593-
Map(old_labeller, names(labels), labels)
594-
}
586+
if (!is_deprecated) {
587+
return(invisible())
595588
}
596589

597-
labeller
590+
lifecycle::deprecate_stop(
591+
"2.0.0",
592+
what = I("Providing a labeller with `variable` and `value` arguments")
593+
)
598594
}

0 commit comments

Comments
 (0)