From 220a07490fa30177f9b9514c091439b25f5ba0d0 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 4 Aug 2022 11:38:24 -0500 Subject: [PATCH 01/12] Mark funs() as deprecated And revise defunct.Rd --- NEWS.md | 2 + R/defunct.r | 35 +++++++- R/deprec-funs.R | 69 -------------- man/defunct.Rd | 17 +++- man/funs.Rd | 47 ---------- tests/testthat/_snaps/defunct.md | 30 +++++++ tests/testthat/_snaps/deprec-funs.md | 38 -------- tests/testthat/test-defunct.r | 7 ++ tests/testthat/test-deprec-funs.R | 130 --------------------------- 9 files changed, 85 insertions(+), 290 deletions(-) delete mode 100644 R/deprec-funs.R delete mode 100644 man/funs.Rd create mode 100644 tests/testthat/_snaps/defunct.md delete mode 100644 tests/testthat/_snaps/deprec-funs.md create mode 100644 tests/testthat/test-defunct.r delete mode 100644 tests/testthat/test-deprec-funs.R diff --git a/NEWS.md b/NEWS.md index 134151c23b..32b5904549 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # dplyr (development version) +* `funs()`, deprecated in 0.8.0, is now defunct (#6387). + * Passing `...` to `across()` is now deprecated because the evaluation timing of `...` is ambiguous. Now instead of (e.g.) `across(a:b, mean, na.rm = TRUE)` you should write `across(a:b, ~ mean(.x, na.rm = TRUE))` (#6073). diff --git a/R/defunct.r b/R/defunct.r index a4495085f6..9c8a7c3589 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -1,21 +1,52 @@ #' Defunct functions #' -#' `r lifecycle::badge("deprecated")` +#' @description +#' `r lifecycle::badge("defunct")` #' -#' Executing these functions will tell you which function replaces them. +#' These function were all deprecated for at least two years and are now +#' defunct. Executing them to tell you which function to use instead. #' #' @keywords internal #' @name defunct NULL +#' @usage # Deprecated in 0.5.0 ------------------------------------- +#' @name defunct +NULL + #' @export #' @rdname defunct id <- function(.variables, drop = FALSE) { lifecycle::deprecate_stop("0.5.0", "id()", "vctrs::vec_group_id()") } +#' @usage # Deprecated in 0.7.0 ------------------------------------- +#' @name defunct +NULL + #' @export #' @rdname defunct failwith <- function(default = NULL, f, quiet = FALSE) { lifecycle::deprecate_stop("0.7.0", "failwith()", "purrr::possibly()") } + +#' @usage # Deprecated in 0.8.* ------------------------------------- +#' @name defunct +NULL + +#' @export +#' @rdname defunct +funs <- function(..., .args = list()) { + lifecycle::deprecate_stop("0.8.0", "funs()", details = paste_line( + "Please use a list of either functions or lambdas: ", + "", + " # Simple named list: ", + " list(mean = mean, median = median)", + "", + " # Auto named with `tibble::lst()`: ", + " tibble::lst(mean, median)", + "", + " # Using lambdas", + " list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))" + )) +} diff --git a/R/deprec-funs.R b/R/deprec-funs.R deleted file mode 100644 index da87eec953..0000000000 --- a/R/deprec-funs.R +++ /dev/null @@ -1,69 +0,0 @@ -#' Create a list of function calls -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' `funs()` is deprecated; please use `list()` instead. We deprecated this -#' function because it provided a unique way of specifying anonymous functions, -#' rather than adopting the conventions used by purrr and other packages -#' in the tidyverse. -#' -#' @param ... <[`data-masking`][dplyr_data_masking]> A list of functions -#' specified by: -#' -#' - Their name, `"mean"` -#' - The function itself, `mean` -#' - A call to the function with `.` as a dummy argument, -#' `mean(., na.rm = TRUE)` -#' -#' The following notations are **not** supported, see examples: -#' -#' - An anonymous function, `function(x) mean(x, na.rm = TRUE)` -#' - An anonymous function in \pkg{purrr} notation, `~mean(., na.rm = TRUE)` -#' -#' @param .args,args A named list of additional arguments to be added to all -#' function calls. As `funs()` is being deprecated, use other methods to -#' supply arguments: `...` argument in [scoped verbs][summarise_at()] or make -#' own functions with [purrr::partial()]. -#' @export -#' @keywords internal -#' @examples -#' funs("mean", mean(., na.rm = TRUE)) -#' # -> -#' list(mean = mean, mean = ~ mean(.x, na.rm = TRUE)) -#' -#' funs(m1 = mean, m2 = "mean", m3 = mean(., na.rm = TRUE)) -#' # -> -#' list(m1 = mean, m2 = "mean", m3 = ~ mean(.x, na.rm = TRUE)) -funs <- function(..., .args = list()) { - lifecycle::deprecate_warn("0.8.0", "funs()", details = paste_line( - "Please use a list of either functions or lambdas: ", - "", - " # Simple named list: ", - " list(mean = mean, median = median)", - "", - " # Auto named with `tibble::lst()`: ", - " tibble::lst(mean, median)", - "", - " # Using lambdas", - " list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))" - )) - - dots <- enquos(...) - default_env <- caller_env() - - error_call <- current_env() - funs <- map(dots, function(quo) as_fun(quo, default_env, .args, error_call = error_call)) - new_funs(funs) -} -new_funs <- function(funs) { - attr(funs, "have_name") <- any(names2(funs) != "") - - # Workaround until rlang:::label() is exported - temp <- map(funs, function(fn) node_car(quo_get_expr(fn))) - temp <- exprs_auto_name(temp) - names(funs) <- names(temp) - - class(funs) <- "fun_list" - funs -} diff --git a/man/defunct.Rd b/man/defunct.Rd index b9a8afcafb..96240d9406 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -4,16 +4,25 @@ \alias{defunct} \alias{id} \alias{failwith} +\alias{funs} \title{Defunct functions} \usage{ +# Deprecated in 0.5.0 ------------------------------------- + id(.variables, drop = FALSE) +# Deprecated in 0.7.0 ------------------------------------- + failwith(default = NULL, f, quiet = FALSE) + +# Deprecated in 0.8.* ------------------------------------- + +funs(..., .args = list()) } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -} -\details{ -Executing these functions will tell you which function replaces them. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} + +These function were all deprecated for at least two years and are now +defunct. Executing them to tell you which function to use instead. } \keyword{internal} diff --git a/man/funs.Rd b/man/funs.Rd deleted file mode 100644 index 3797347f98..0000000000 --- a/man/funs.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprec-funs.R -\name{funs} -\alias{funs} -\title{Create a list of function calls} -\usage{ -funs(..., .args = list()) -} -\arguments{ -\item{...}{<\code{\link[=dplyr_data_masking]{data-masking}}> A list of functions -specified by: -\itemize{ -\item Their name, \code{"mean"} -\item The function itself, \code{mean} -\item A call to the function with \code{.} as a dummy argument, -\code{mean(., na.rm = TRUE)} -} - -The following notations are \strong{not} supported, see examples: -\itemize{ -\item An anonymous function, \code{function(x) mean(x, na.rm = TRUE)} -\item An anonymous function in \pkg{purrr} notation, \code{~mean(., na.rm = TRUE)} -}} - -\item{.args, args}{A named list of additional arguments to be added to all -function calls. As \code{funs()} is being deprecated, use other methods to -supply arguments: \code{...} argument in \link[=summarise_at]{scoped verbs} or make -own functions with \code{\link[purrr:partial]{purrr::partial()}}.} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -\code{funs()} is deprecated; please use \code{list()} instead. We deprecated this -function because it provided a unique way of specifying anonymous functions, -rather than adopting the conventions used by purrr and other packages -in the tidyverse. -} -\examples{ -funs("mean", mean(., na.rm = TRUE)) -# -> -list(mean = mean, mean = ~ mean(.x, na.rm = TRUE)) - -funs(m1 = mean, m2 = "mean", m3 = mean(., na.rm = TRUE)) -# -> -list(m1 = mean, m2 = "mean", m3 = ~ mean(.x, na.rm = TRUE)) -} -\keyword{internal} diff --git a/tests/testthat/_snaps/defunct.md b/tests/testthat/_snaps/defunct.md new file mode 100644 index 0000000000..50b1af1df0 --- /dev/null +++ b/tests/testthat/_snaps/defunct.md @@ -0,0 +1,30 @@ +# generate informative errors + + Code + id() + Condition + Error: + ! `id()` was deprecated in dplyr 0.5.0 and is now defunct. + Please use `vctrs::vec_group_id()` instead. + Code + failwith() + Condition + Error: + ! `failwith()` was deprecated in dplyr 0.7.0 and is now defunct. + Please use `purrr::possibly()` instead. + Code + funs() + Condition + Error: + ! `funs()` was deprecated in dplyr 0.8.0 and is now defunct. + Please use a list of either functions or lambdas: + + # Simple named list: + list(mean = mean, median = median) + + # Auto named with `tibble::lst()`: + tibble::lst(mean, median) + + # Using lambdas + list(~ mean(., trim = .2), ~ median(., na.rm = TRUE)) + diff --git a/tests/testthat/_snaps/deprec-funs.md b/tests/testthat/_snaps/deprec-funs.md deleted file mode 100644 index 96afe1f7a3..0000000000 --- a/tests/testthat/_snaps/deprec-funs.md +++ /dev/null @@ -1,38 +0,0 @@ -# funs() is deprecated - - Code - funs(fn = bar) - Condition - Warning: - `funs()` was deprecated in dplyr 0.8.0. - Please use a list of either functions or lambdas: - - # Simple named list: - list(mean = mean, median = median) - - # Auto named with `tibble::lst()`: - tibble::lst(mean, median) - - # Using lambdas - list(~ mean(., trim = .2), ~ median(., na.rm = TRUE)) - Output - - $ fn: bar(.) - -# funs() give meaningful error messages - - Code - (expect_error(funs(function(si) { - mp[si] - }))) - Output - - Error in `funs()`: - ! `function(si) { mp[si] }` must be a function name (quoted or unquoted) or an unquoted call, not `function`. - Code - (expect_error(funs(~ mp[.]))) - Output - - Error in `funs()`: - ! `~mp[.]` must be a function name (quoted or unquoted) or an unquoted call, not `~`. - diff --git a/tests/testthat/test-defunct.r b/tests/testthat/test-defunct.r new file mode 100644 index 0000000000..a9daf4767d --- /dev/null +++ b/tests/testthat/test-defunct.r @@ -0,0 +1,7 @@ +test_that("generate informative errors", { + expect_snapshot(error = TRUE, { + id() + failwith() + funs() + }) +}) diff --git a/tests/testthat/test-deprec-funs.R b/tests/testthat/test-deprec-funs.R deleted file mode 100644 index 52dad27059..0000000000 --- a/tests/testthat/test-deprec-funs.R +++ /dev/null @@ -1,130 +0,0 @@ -test_that("fun_list is merged with new args", { - withr::local_options(lifecycle_verbosity = "quiet") - - funs <- funs(fn = bar) - funs <- as_fun_list(funs, env(), baz = "baz") - expect_identical(funs$fn, quo(bar(., baz = "baz"))) -}) - -test_that("funs() works with namespaced calls", { - withr::local_options(lifecycle_verbosity = "quiet") - - expect_identical(summarise_all(mtcars, funs(base::mean(.))), summarise_all(mtcars, funs(mean(.)))) - expect_identical(summarise_all(mtcars, funs(base::mean)), summarise_all(mtcars, funs(mean(.)))) -}) - -test_that("funs() found in local environment", { - withr::local_options(lifecycle_verbosity = "quiet") - - f <- function(x) 1 - df <- data.frame(x = c(2:10, 1000)) - - out <- summarise_all(df, funs(f = f, mean = mean, median = median)) - expect_equal(out, data.frame(f = 1, mean = 105.4, median = 6.5)) -}) - -test_that("funs() accepts quoted functions", { - withr::local_options(lifecycle_verbosity = "quiet") - - expect_identical(funs(mean), funs("mean")) -}) - -test_that("funs() accepts unquoted functions", { - withr::local_options(lifecycle_verbosity = "quiet") - - funs <- funs(fn = !!mean) - expect_identical(funs$fn, new_quosure(call2(base::mean, quote(.)))) -}) - -test_that("funs() accepts quoted calls", { - withr::local_options(lifecycle_verbosity = "quiet") - - expect_identical(funs(mean), funs(mean(.))) -}) - -test_that("funs() can be merged with new arguments", { - withr::local_options(lifecycle_verbosity = "quiet") - - fns <- funs(foo(.)) - expect_identical(as_fun_list(fns, current_env(), foo = 1L), funs(foo(., foo = 1L))) -}) - -enfun <- function(.funs, ...) { - as_fun_list(.funs, caller_env(), ...) -} - -test_that("can enfun() literal functions", { - res <- enfun(identity(mean)) - expect_equal(length(res), 1L) - expect_identical(res[[1L]], mean) -}) - -test_that("can enfun() named functions by expression", { - res <- enfun(mean) - expect_equal(length(res), 1L) - expect_identical(res[[1L]], mean) -}) - -test_that("local objects are not treated as symbols", { - withr::local_options(lifecycle_verbosity = "quiet") - - mean <- funs(my_mean(.)) - expect_identical(enfun(mean), mean) -}) - -test_that("can enfun() character vectors", { - res <- enfun(c("min", "max")) - expect_equal(length(res), 2L) - expect_equal(res[[1]], min) - expect_equal(res[[2]], max) -}) - -test_that("can enfun() purrr-style lambdas", { - my_mean <- as_function(~ mean(.x)) - res <- enfun(~ mean(.x)) - expect_equal(length(res), 1L) - expect_type(res[[1]], "closure") -}) - -test_that("funs_ works", { - withr::local_options(lifecycle_verbosity = "quiet") - - expect_equal( - funs(mean), - funs_(list(~ mean)) - ) - - expect_equal( - funs_(list("mean")), - funs_(list(`environment<-`(~ mean, baseenv()))), - ignore_formula_env = TRUE - ) - - expect_equal( - funs(mean(.)), - funs_(list(~ mean(.))) - ) -}) - -test_that("as_fun_list() auto names chr vectors (4307)", { - expect_identical( - data.frame(x = 1:10) %>% summarise_at("x", c("mean", "sum")), - data.frame(x = 1:10) %>% summarise(mean = mean(x), sum = sum(x)) - ) -}) - -test_that("funs() is deprecated", { - expect_snapshot(funs(fn = bar)) -}) - -# Errors ------------------------------------------------------------------ - -test_that("funs() give meaningful error messages", { - withr::local_options(lifecycle_verbosity = "quiet") - - expect_snapshot({ - (expect_error(funs(function(si) { mp[si] }))) - (expect_error(funs(~ mp[.])) ) - }) - -}) From c364f0c0952b9e0e27c34c290d473786422e2774 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 4 Aug 2022 16:41:58 -0500 Subject: [PATCH 02/12] Deprecate tidyselect wrappers --- NEWS.md | 3 +++ R/defunct.r | 22 +++++++++++++++++++++ R/deprec-tidyselect.R | 33 -------------------------------- man/defunct.Rd | 12 ++++++++++++ man/select_vars.Rd | 25 ------------------------ tests/testthat/_snaps/defunct.md | 24 +++++++++++++++++++++++ tests/testthat/test-defunct.r | 4 ++++ 7 files changed, 65 insertions(+), 58 deletions(-) delete mode 100644 R/deprec-tidyselect.R delete mode 100644 man/select_vars.Rd diff --git a/NEWS.md b/NEWS.md index 32b5904549..e3afe0c479 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ * `funs()`, deprecated in 0.8.0, is now defunct (#6387). +* `select_vars()`, `rename_vars()`, `select_var()` and `current_var()`, + deprecated in 0.8.4, are now defunct (#6387). + * Passing `...` to `across()` is now deprecated because the evaluation timing of `...` is ambiguous. Now instead of (e.g.) `across(a:b, mean, na.rm = TRUE)` you should write `across(a:b, ~ mean(.x, na.rm = TRUE))` (#6073). diff --git a/R/defunct.r b/R/defunct.r index 9c8a7c3589..844afd2318 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -50,3 +50,25 @@ funs <- function(..., .args = list()) { " list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))" )) } + +#' @export +#' @rdname defunct +select_vars <- function(vars = chr(), ..., include = chr(), exclude = chr()) { + lifecycle::deprecate_stop("0.8.4", "select_vars()", "tidyselect::vars_select()") +} +#' @export +#' @rdname defunct +rename_vars <- function(vars = chr(), ..., strict = TRUE) { + lifecycle::deprecate_stop("0.8.4", "rename_vars()", "tidyselect::vars_rename()") +} +#' @export +#' @rdname defunct +select_var <- function(vars, var = -1) { + lifecycle::deprecate_stop("0.8.4", "select_var()", "tidyselect::vars_pull()") +} +#' @export +#' @rdname defunct +current_vars <- function(...) { + lifecycle::deprecate_stop("0.8.4", "current_vars()", "tidyselect::peek_vars()") +} + diff --git a/R/deprec-tidyselect.R b/R/deprec-tidyselect.R deleted file mode 100644 index 9159de9dff..0000000000 --- a/R/deprec-tidyselect.R +++ /dev/null @@ -1,33 +0,0 @@ -#' Select variables -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' These functions now live in the tidyselect package as -#' [tidyselect::vars_select()], [tidyselect::vars_rename()] and -#' [tidyselect::vars_pull()]. -#' -#' @keywords internal -#' @export -select_vars <- function(vars = chr(), ..., include = chr(), exclude = chr()) { - lifecycle::deprecate_warn("0.8.4", "select_vars()", "tidyselect::vars_select()") - tidyselect::vars_select(.vars = vars, ..., .include = include, .exclude = exclude) -} -#' @rdname select_vars -#' @export -rename_vars <- function(vars = chr(), ..., strict = TRUE) { - lifecycle::deprecate_warn("0.8.4", "rename_vars()", "tidyselect::vars_rename()") - tidyselect::vars_rename(.vars = vars, ..., .strict = strict) -} -#' @rdname select_vars -#' @export -select_var <- function(vars, var = -1) { - lifecycle::deprecate_warn("0.8.4", "select_var()", "tidyselect::vars_pull()") - tidyselect::vars_pull(vars, !!enquo(var)) -} -#' @rdname select_vars -#' @export -current_vars <- function(...) { - lifecycle::deprecate_warn("0.8.4", "current_vars()", "tidyselect::peek_vars()") - tidyselect::peek_vars(...) -} diff --git a/man/defunct.Rd b/man/defunct.Rd index 96240d9406..9ac5c483e0 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -5,6 +5,10 @@ \alias{id} \alias{failwith} \alias{funs} +\alias{select_vars} +\alias{rename_vars} +\alias{select_var} +\alias{current_vars} \title{Defunct functions} \usage{ # Deprecated in 0.5.0 ------------------------------------- @@ -18,6 +22,14 @@ failwith(default = NULL, f, quiet = FALSE) # Deprecated in 0.8.* ------------------------------------- funs(..., .args = list()) + +select_vars(vars = chr(), ..., include = chr(), exclude = chr()) + +rename_vars(vars = chr(), ..., strict = TRUE) + +select_var(vars, var = -1) + +current_vars(...) } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} diff --git a/man/select_vars.Rd b/man/select_vars.Rd deleted file mode 100644 index 63a9f4d867..0000000000 --- a/man/select_vars.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprec-tidyselect.R -\name{select_vars} -\alias{select_vars} -\alias{rename_vars} -\alias{select_var} -\alias{current_vars} -\title{Select variables} -\usage{ -select_vars(vars = chr(), ..., include = chr(), exclude = chr()) - -rename_vars(vars = chr(), ..., strict = TRUE) - -select_var(vars, var = -1) - -current_vars(...) -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -These functions now live in the tidyselect package as -\code{\link[tidyselect:vars_select]{tidyselect::vars_select()}}, \code{\link[tidyselect:vars_select]{tidyselect::vars_rename()}} and -\code{\link[tidyselect:vars_pull]{tidyselect::vars_pull()}}. -} -\keyword{internal} diff --git a/tests/testthat/_snaps/defunct.md b/tests/testthat/_snaps/defunct.md index 50b1af1df0..9a3f7ed2a6 100644 --- a/tests/testthat/_snaps/defunct.md +++ b/tests/testthat/_snaps/defunct.md @@ -27,4 +27,28 @@ # Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE)) + Code + select_vars() + Condition + Error: + ! `select_vars()` was deprecated in dplyr 0.8.4 and is now defunct. + Please use `tidyselect::vars_select()` instead. + Code + rename_vars() + Condition + Error: + ! `rename_vars()` was deprecated in dplyr 0.8.4 and is now defunct. + Please use `tidyselect::vars_rename()` instead. + Code + select_var() + Condition + Error: + ! `select_var()` was deprecated in dplyr 0.8.4 and is now defunct. + Please use `tidyselect::vars_pull()` instead. + Code + current_vars() + Condition + Error: + ! `current_vars()` was deprecated in dplyr 0.8.4 and is now defunct. + Please use `tidyselect::peek_vars()` instead. diff --git a/tests/testthat/test-defunct.r b/tests/testthat/test-defunct.r index a9daf4767d..949fd615be 100644 --- a/tests/testthat/test-defunct.r +++ b/tests/testthat/test-defunct.r @@ -3,5 +3,9 @@ test_that("generate informative errors", { id() failwith() funs() + select_vars() + rename_vars() + select_var() + current_vars() }) }) From 4878d345b11b23ed7673cfa921471cf2e1cc47d7 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 4 Aug 2022 16:50:35 -0500 Subject: [PATCH 03/12] Defunct bench_tbl and friends --- NEWS.md | 3 + R/defunct.r | 29 ++++++++ R/deprec-bench-compare.r | 112 ------------------------------- man/bench_compare.Rd | 57 ---------------- man/defunct.Rd | 15 +++++ tests/testthat/_snaps/defunct.md | 25 +++++++ tests/testthat/test-defunct.r | 9 +++ 7 files changed, 81 insertions(+), 169 deletions(-) delete mode 100644 R/deprec-bench-compare.r delete mode 100644 man/bench_compare.Rd diff --git a/NEWS.md b/NEWS.md index e3afe0c479..2af7ae435a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,9 @@ * `select_vars()`, `rename_vars()`, `select_var()` and `current_var()`, deprecated in 0.8.4, are now defunct (#6387). +* `bench_tbls()`, `compare_tbls()`, `compare_tbls2()`, `eval_tbls()`, and + `eval_tbl()`, deprecated in 1.0.0, are now defunct (#6387). + * Passing `...` to `across()` is now deprecated because the evaluation timing of `...` is ambiguous. Now instead of (e.g.) `across(a:b, mean, na.rm = TRUE)` you should write `across(a:b, ~ mean(.x, na.rm = TRUE))` (#6073). diff --git a/R/defunct.r b/R/defunct.r index 844afd2318..d1b801ae10 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -72,3 +72,32 @@ current_vars <- function(...) { lifecycle::deprecate_stop("0.8.4", "current_vars()", "tidyselect::peek_vars()") } +#' @export +#' @rdname defunct +bench_tbls <- function(tbls, op, ..., times = 10) { + lifecycle::deprecate_stop("1.0.0", "bench_tbls()") +} + +#' @export +#' @rdname defunct +compare_tbls <- function(tbls, op, ref = NULL, compare = equal_data_frame, ...) { + lifecycle::deprecate_stop("1.0.0", "compare_tbls()") +} + +#' @export +#' @rdname defunct +compare_tbls2 <- function(tbls_x, tbls_y, op, ref = NULL, compare = equal_data_frame, ...) { + lifecycle::deprecate_stop("1.0.0", "compare_tbls2()") +} + +#' @export +#' @rdname defunct +eval_tbls <- function(tbls, op) { + lifecycle::deprecate_stop("1.0.0", "eval_tbls()") +} + +#' @export +#' @rdname defunct +eval_tbls2 <- function(tbls_x, tbls_y, op) { + lifecycle::deprecate_stop("1.0.0", "eval_tbls2()") +} diff --git a/R/deprec-bench-compare.r b/R/deprec-bench-compare.r deleted file mode 100644 index df9cc06732..0000000000 --- a/R/deprec-bench-compare.r +++ /dev/null @@ -1,112 +0,0 @@ -#' Evaluate, compare, benchmark operations of a set of srcs. -#' -#' `r lifecycle::badge("deprecated")` -#' These functions are deprecated because we now believe that you're -#' better of performing the comparisons directly, yourself, in order to -#' generate more informative test failures. -#' -#' @param tbls,tbls_x,tbls_y A list of [tbl()]s. -#' @param op A function with a single argument, called often with each -#' element of `tbls`. -#' @param ref For checking, a data frame to test results against. If not -#' supplied, defaults to the results from the first `src`. -#' @param compare A function used to compare the results. Defaults to -#' `equal_data_frame` which ignores the order of rows and columns. -#' @param times For benchmarking, the number of times each operation is -#' repeated. -#' @param \dots -#' For `compare_tbls()`: additional parameters passed on the -#' `compare()` function -#' -#' For `bench_tbls()`: additional benchmarks to run. -#' @return -#' `eval_tbls()`: a list of data frames. -#' -#' `compare_tbls()`: an invisible `TRUE` on success, otherwise -#' an error is thrown. -#' -#' `bench_tbls()`: an object of class -#' [microbenchmark::microbenchmark()] -#' @name bench_compare -#' @keywords internal -NULL - -#' @export -#' @rdname bench_compare -bench_tbls <- function(tbls, op, ..., times = 10) { - lifecycle::deprecate_warn("1.0.0", "bench_tbls()") - check_installed("microbenchmark", "to compute table benchmarks.") - - # Generate call to microbenchmark function that evaluates op for each tbl - calls <- lapply(seq_along(tbls), function(i) { - substitute(op(tbls[[i]]), list(i = i)) - }) - names(calls) <- names(tbls) - - mb <- as.call(c( - quote(microbenchmark::microbenchmark), calls, dots(...), - list(times = times) - )) - eval(mb) -} - -#' @export -#' @rdname bench_compare -compare_tbls <- function(tbls, op, ref = NULL, compare = equal_data_frame, ...) { - lifecycle::deprecate_warn("1.0.0", "compare_tbls()") - - results <- eval_tbls(tbls, op) - expect_equal_tbls(results, compare = compare, ...) -} - -#' @export -#' @rdname bench_compare -compare_tbls2 <- function(tbls_x, tbls_y, op, ref = NULL, compare = equal_data_frame, ...) { - lifecycle::deprecate_warn("1.0.0", "compare_tbls2()") - - results <- eval_tbls2(tbls_x, tbls_y, op) - expect_equal_tbls(results, compare = compare, ...) -} - -expect_equal_tbls <- function(results, ref = NULL, compare = equal_data_frame, ...) { - check_installed("testthat", "to compare tables.") - - if (length(results) < 2 && is.null(ref)) { - testthat::skip("Need at least two srcs to compare") - } - - if (is.null(ref)) { - ref <- results[[1]] - ref_name <- names(results)[1] - rest <- results[-1] - } else { - rest <- results - ref_name <- "supplied comparison" - } - - for (i in seq_along(rest)) { - ok <- compare(ref, rest[[i]], ...) - # if (!ok) browser() - msg <- paste0( - names(rest)[[i]], " not equal to ", ref_name, "\n", - attr(ok, "comment") - ) - testthat::expect_true(ok, info = msg) - } - - invisible(TRUE) -} - -#' @export -#' @rdname bench_compare -eval_tbls <- function(tbls, op) { - lifecycle::deprecate_warn("1.0.0", "eval_tbls()") - lapply(tbls, function(x) as.data.frame(op(x))) -} - -#' @export -#' @rdname bench_compare -eval_tbls2 <- function(tbls_x, tbls_y, op) { - lifecycle::deprecate_warn("1.0.0", "eval_tbls2()") - Map(function(x, y) as.data.frame(op(x, y)), tbls_x, tbls_y) -} diff --git a/man/bench_compare.Rd b/man/bench_compare.Rd deleted file mode 100644 index 0e906f743e..0000000000 --- a/man/bench_compare.Rd +++ /dev/null @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprec-bench-compare.r -\name{bench_compare} -\alias{bench_compare} -\alias{bench_tbls} -\alias{compare_tbls} -\alias{compare_tbls2} -\alias{eval_tbls} -\alias{eval_tbls2} -\title{Evaluate, compare, benchmark operations of a set of srcs.} -\usage{ -bench_tbls(tbls, op, ..., times = 10) - -compare_tbls(tbls, op, ref = NULL, compare = equal_data_frame, ...) - -compare_tbls2(tbls_x, tbls_y, op, ref = NULL, compare = equal_data_frame, ...) - -eval_tbls(tbls, op) - -eval_tbls2(tbls_x, tbls_y, op) -} -\arguments{ -\item{tbls, tbls_x, tbls_y}{A list of \code{\link[=tbl]{tbl()}}s.} - -\item{op}{A function with a single argument, called often with each -element of \code{tbls}.} - -\item{\dots}{For \code{compare_tbls()}: additional parameters passed on the -\code{compare()} function - -For \code{bench_tbls()}: additional benchmarks to run.} - -\item{times}{For benchmarking, the number of times each operation is -repeated.} - -\item{ref}{For checking, a data frame to test results against. If not -supplied, defaults to the results from the first \code{src}.} - -\item{compare}{A function used to compare the results. Defaults to -\code{equal_data_frame} which ignores the order of rows and columns.} -} -\value{ -\code{eval_tbls()}: a list of data frames. - -\code{compare_tbls()}: an invisible \code{TRUE} on success, otherwise -an error is thrown. - -\code{bench_tbls()}: an object of class -\code{\link[microbenchmark:microbenchmark]{microbenchmark::microbenchmark()}} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -These functions are deprecated because we now believe that you're -better of performing the comparisons directly, yourself, in order to -generate more informative test failures. -} -\keyword{internal} diff --git a/man/defunct.Rd b/man/defunct.Rd index 9ac5c483e0..8bae5cf577 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -9,6 +9,11 @@ \alias{rename_vars} \alias{select_var} \alias{current_vars} +\alias{bench_tbls} +\alias{compare_tbls} +\alias{compare_tbls2} +\alias{eval_tbls} +\alias{eval_tbls2} \title{Defunct functions} \usage{ # Deprecated in 0.5.0 ------------------------------------- @@ -30,6 +35,16 @@ rename_vars(vars = chr(), ..., strict = TRUE) select_var(vars, var = -1) current_vars(...) + +bench_tbls(tbls, op, ..., times = 10) + +compare_tbls(tbls, op, ref = NULL, compare = equal_data_frame, ...) + +compare_tbls2(tbls_x, tbls_y, op, ref = NULL, compare = equal_data_frame, ...) + +eval_tbls(tbls, op) + +eval_tbls2(tbls_x, tbls_y, op) } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} diff --git a/tests/testthat/_snaps/defunct.md b/tests/testthat/_snaps/defunct.md index 9a3f7ed2a6..6e6856433d 100644 --- a/tests/testthat/_snaps/defunct.md +++ b/tests/testthat/_snaps/defunct.md @@ -51,4 +51,29 @@ Error: ! `current_vars()` was deprecated in dplyr 0.8.4 and is now defunct. Please use `tidyselect::peek_vars()` instead. + Code + bench_tbl() + Condition + Error in `bench_tbl()`: + ! could not find function "bench_tbl" + Code + compare_tbls() + Condition + Error: + ! `compare_tbls()` was deprecated in dplyr 1.0.0 and is now defunct. + Code + compare_tbls2() + Condition + Error: + ! `compare_tbls2()` was deprecated in dplyr 1.0.0 and is now defunct. + Code + eval_tbls() + Condition + Error: + ! `eval_tbls()` was deprecated in dplyr 1.0.0 and is now defunct. + Code + eval_tbls2() + Condition + Error: + ! `eval_tbls2()` was deprecated in dplyr 1.0.0 and is now defunct. diff --git a/tests/testthat/test-defunct.r b/tests/testthat/test-defunct.r index 949fd615be..ed74d2f96a 100644 --- a/tests/testthat/test-defunct.r +++ b/tests/testthat/test-defunct.r @@ -1,11 +1,20 @@ test_that("generate informative errors", { expect_snapshot(error = TRUE, { id() + failwith() + funs() + select_vars() rename_vars() select_var() current_vars() + + bench_tbl() + compare_tbls() + compare_tbls2() + eval_tbls() + eval_tbls2() }) }) From b9a7013c436014d47b9c444ada16ed8081f5d43f Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 4 Aug 2022 17:15:05 -0500 Subject: [PATCH 04/12] Defunct location() + changes() --- NAMESPACE | 1 - NEWS.md | 2 + R/defunct.r | 16 +++++ R/deprec-location.R | 106 ------------------------------- man/defunct.Rd | 8 +++ man/location.Rd | 36 ----------- tests/testthat/_snaps/defunct.md | 12 ++++ tests/testthat/test-defunct.r | 3 + 8 files changed, 41 insertions(+), 143 deletions(-) delete mode 100644 R/deprec-location.R delete mode 100644 man/location.Rd diff --git a/NAMESPACE b/NAMESPACE index e1554e8ffc..8d653bec61 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -114,7 +114,6 @@ S3method(print,any_vars) S3method(print,dplyr_join_by) S3method(print,dplyr_sel_vars) S3method(print,fun_list) -S3method(print,location) S3method(print,src) S3method(pull,data.frame) S3method(rbind,grouped_df) diff --git a/NEWS.md b/NEWS.md index 2af7ae435a..4926b23fa7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ * `bench_tbls()`, `compare_tbls()`, `compare_tbls2()`, `eval_tbls()`, and `eval_tbl()`, deprecated in 1.0.0, are now defunct (#6387). +* `location()` and `changes()`, deprecated in 1.0.0, are now defunct (#6387). + * Passing `...` to `across()` is now deprecated because the evaluation timing of `...` is ambiguous. Now instead of (e.g.) `across(a:b, mean, na.rm = TRUE)` you should write `across(a:b, ~ mean(.x, na.rm = TRUE))` (#6073). diff --git a/R/defunct.r b/R/defunct.r index d1b801ae10..5e0bfc3970 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -72,6 +72,10 @@ current_vars <- function(...) { lifecycle::deprecate_stop("0.8.4", "current_vars()", "tidyselect::peek_vars()") } +#' @usage # Deprecated in 1.0.0 ------------------------------------- +#' @name defunct +NULL + #' @export #' @rdname defunct bench_tbls <- function(tbls, op, ..., times = 10) { @@ -101,3 +105,15 @@ eval_tbls <- function(tbls, op) { eval_tbls2 <- function(tbls_x, tbls_y, op) { lifecycle::deprecate_stop("1.0.0", "eval_tbls2()") } + +#' @export +#' @rdname defunct +location <- function(df) { + lifecycle::deprecate_stop("1.0.0", "location()", "lobst::ref()") +} + +#' @export +#' @rdname defunct +changes <- function(x, y) { + lifecycle::deprecate_stop("1.0.0", "changes()", "lobstr::ref()") +} diff --git a/R/deprec-location.R b/R/deprec-location.R deleted file mode 100644 index a8517c3706..0000000000 --- a/R/deprec-location.R +++ /dev/null @@ -1,106 +0,0 @@ -#' Print the location in memory of a data frame -#' -#' @description -#' `r lifecycle::badge("deprecated")` -#' -#' This is useful for understand how and when dplyr makes copies of data -#' frames -#' -#' @param df a data frame -#' @param x,y two data frames to compare -#' @keywords internal -#' @export -#' -#' @examples -#' location(mtcars) -#' # -> -#' lobstr::ref(mtcars) -#' -#' mtcars2 <- mutate(mtcars, cyl2 = cyl * 2) -#' # -> -#' lobstr::ref(mtcars2) -#' -#' changes(mtcars, mtcars2) -#' # -> -#' lobstr::ref(mtcars, mtcars2) -location <- function(df) { - lifecycle::deprecate_warn("1.0.0", "location()", "lobst::ref()") - - check_installed("lobstr", "to compute package locations.") - - if (!is.data.frame(df)) { - abort("`location()` is meant for data frames.") - } - - attrs <- attributes(df) - structure(list( - df = lobstr::obj_addr(df), - vars = set_names(lobstr::obj_addrs(df), names(df)), - attr = set_names(lobstr::obj_addrs(attrs), names(attrs)) - ), class = "location") -} - -#' @export -print.location <- function(x, ...) { - cat("<", x$df, ">\n", sep = "") - - width <- max(nchar(c(names(x$vars), names(x$attr)))) + 1 - def_list <- function(x) { - term <- format(paste0(names(x), ":"), width = width) - paste0(" * ", term, " <", format(x), ">") - } - - vars <- paste0(def_list(x$vars), collapse = "\n") - cat("Variables:\n", vars, "\n", sep = "") - - attr <- paste0(def_list(x$attr), collapse = "\n") - cat("Attributes:\n", attr, "\n", sep = "") - invisible(x) -} - -#' @rdname location -#' @export -changes <- function(x, y) { - lifecycle::deprecate_warn("1.0.0", "changes()", "lobstr::ref()") - - x <- location(x) - y <- location(y) - - if (x$df == y$df) { - cat("\n") - return(invisible()) - } - - # match up x vars to y vars - vars <- match_up(x$vars, y$vars) - attr <- match_up(x$attr, y$attr) - - width <- max(nchar(rownames(vars)), nchar(rownames(attr))) - if (nrow(vars) > 0) rownames(vars) <- format(rownames(vars), width = width) - if (nrow(attr) > 0) rownames(attr) <- format(rownames(attr), width = width) - - if (nrow(vars) > 0) { - cat("Changed variables:\n") - print(vars, quote = FALSE) - } - - if (nrow(vars) > 0 && nrow(attr)) cat("\n") - - if (nrow(attr) > 0) { - cat("Changed attributes:\n") - print(attr, quote = FALSE) - } -} - -match_up <- function(x, y) { - both <- intersect(names(x), names(y)) - added <- setdiff(names(x), names(y)) - deleted <- setdiff(names(y), names(x)) - - out <- cbind( - old = c(x[both], x[added], rep("", length(deleted))), - new = c(y[both], rep("", length(added)), y[deleted]) - ) - rownames(out) <- c(both, added, deleted) - out[out[, "old"] != out[, "new"], , drop = FALSE] -} diff --git a/man/defunct.Rd b/man/defunct.Rd index 8bae5cf577..4c5663b473 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -14,6 +14,8 @@ \alias{compare_tbls2} \alias{eval_tbls} \alias{eval_tbls2} +\alias{location} +\alias{changes} \title{Defunct functions} \usage{ # Deprecated in 0.5.0 ------------------------------------- @@ -36,6 +38,8 @@ select_var(vars, var = -1) current_vars(...) +# Deprecated in 1.0.0 ------------------------------------- + bench_tbls(tbls, op, ..., times = 10) compare_tbls(tbls, op, ref = NULL, compare = equal_data_frame, ...) @@ -45,6 +49,10 @@ compare_tbls2(tbls_x, tbls_y, op, ref = NULL, compare = equal_data_frame, ...) eval_tbls(tbls, op) eval_tbls2(tbls_x, tbls_y, op) + +location(df) + +changes(x, y) } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} diff --git a/man/location.Rd b/man/location.Rd deleted file mode 100644 index d08c201a20..0000000000 --- a/man/location.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/deprec-location.R -\name{location} -\alias{location} -\alias{changes} -\title{Print the location in memory of a data frame} -\usage{ -location(df) - -changes(x, y) -} -\arguments{ -\item{df}{a data frame} - -\item{x, y}{two data frames to compare} -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} - -This is useful for understand how and when dplyr makes copies of data -frames -} -\examples{ -location(mtcars) -# -> -lobstr::ref(mtcars) - -mtcars2 <- mutate(mtcars, cyl2 = cyl * 2) -# -> -lobstr::ref(mtcars2) - -changes(mtcars, mtcars2) -# -> -lobstr::ref(mtcars, mtcars2) -} -\keyword{internal} diff --git a/tests/testthat/_snaps/defunct.md b/tests/testthat/_snaps/defunct.md index 6e6856433d..e93afda5fb 100644 --- a/tests/testthat/_snaps/defunct.md +++ b/tests/testthat/_snaps/defunct.md @@ -76,4 +76,16 @@ Condition Error: ! `eval_tbls2()` was deprecated in dplyr 1.0.0 and is now defunct. + Code + location() + Condition + Error: + ! `location()` was deprecated in dplyr 1.0.0 and is now defunct. + Please use `lobst::ref()` instead. + Code + changes() + Condition + Error: + ! `changes()` was deprecated in dplyr 1.0.0 and is now defunct. + Please use `lobstr::ref()` instead. diff --git a/tests/testthat/test-defunct.r b/tests/testthat/test-defunct.r index ed74d2f96a..e9e1faf658 100644 --- a/tests/testthat/test-defunct.r +++ b/tests/testthat/test-defunct.r @@ -16,5 +16,8 @@ test_that("generate informative errors", { compare_tbls2() eval_tbls() eval_tbls2() + + location() + changes() }) }) From 7f5f522a2f0d240fdc773128611dc606b727ca9d Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Fri, 5 Aug 2022 08:43:11 -0500 Subject: [PATCH 05/12] No longer need dots() function --- R/utils.r | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/utils.r b/R/utils.r index fcf644a68e..07de4b32cf 100644 --- a/R/utils.r +++ b/R/utils.r @@ -1,7 +1,3 @@ -dots <- function(...) { - eval_bare(substitute(alist(...))) -} - deparse_trunc <- function(x, width = getOption("width")) { text <- deparse(x, width.cutoff = width) if (length(text) == 1 && nchar(text) < width) return(text) From b7a7945cb265a05c0844e24d48828512787b4ed1 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 14:23:26 -0500 Subject: [PATCH 06/12] Use dev lifecycle --- DESCRIPTION | 9 +++++---- tests/testthat/_snaps/across.md | 1 + tests/testthat/_snaps/all-equal.md | 1 + tests/testthat/_snaps/conditions.md | 1 + tests/testthat/_snaps/deprec-combine.md | 1 + tests/testthat/_snaps/select.md | 1 + 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 45cb63de6d..e4cbbf3f14 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,7 @@ Depends: Imports: generics, glue (>= 1.3.2), - lifecycle (>= 1.0.1), + lifecycle (>= 1.0.1.9000), magrittr (>= 1.5), methods, R6, @@ -40,7 +40,7 @@ Imports: tibble (>= 2.1.3), tidyselect (>= 1.1.2.9000), utils, - vctrs (>= 0.4.1.9000), + vctrs (>= 0.4.1.9000), pillar (>= 1.5.1) Suggests: bench, @@ -64,9 +64,10 @@ Suggests: testthat (>= 3.1.1), tidyr, withr -Remotes: +Remotes: r-lib/tidyselect, - r-lib/vctrs + r-lib/vctrs, + r-lib/lifecycle VignetteBuilder: knitr Encoding: UTF-8 diff --git a/tests/testthat/_snaps/across.md b/tests/testthat/_snaps/across.md index 41b8194a29..fb6f3ecdcf 100644 --- a/tests/testthat/_snaps/across.md +++ b/tests/testthat/_snaps/across.md @@ -201,6 +201,7 @@ # Now across(a:b, ~mean(.x, na.rm = TRUE)) + Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. Output # A tibble: 1 x 1 x diff --git a/tests/testthat/_snaps/all-equal.md b/tests/testthat/_snaps/all-equal.md index c885b0dcbb..1ca4a7850d 100644 --- a/tests/testthat/_snaps/all-equal.md +++ b/tests/testthat/_snaps/all-equal.md @@ -7,6 +7,7 @@ `all_equal()` was deprecated in dplyr 1.1.0. Please use `all.equal()` instead. And manually order the rows/cols as needed + Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. Output [1] TRUE diff --git a/tests/testthat/_snaps/conditions.md b/tests/testthat/_snaps/conditions.md index 3a56b26205..e05a218878 100644 --- a/tests/testthat/_snaps/conditions.md +++ b/tests/testthat/_snaps/conditions.md @@ -137,6 +137,7 @@ select(mtcars, 1 + "") Condition Error in `foo()`: + ! Problem while evaluating `1 + ""`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator Code diff --git a/tests/testthat/_snaps/deprec-combine.md b/tests/testthat/_snaps/deprec-combine.md index 9eaf13b8d2..5658661297 100644 --- a/tests/testthat/_snaps/deprec-combine.md +++ b/tests/testthat/_snaps/deprec-combine.md @@ -6,6 +6,7 @@ Warning: `combine()` was deprecated in dplyr 1.0.0. Please use `vctrs::vec_c()` instead. + Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. Output logical(0) diff --git a/tests/testthat/_snaps/select.md b/tests/testthat/_snaps/select.md index af6ad1528f..9c7b1fd309 100644 --- a/tests/testthat/_snaps/select.md +++ b/tests/testthat/_snaps/select.md @@ -30,6 +30,7 @@ Output Error in `select()`: + ! Problem while evaluating `1 + ""`. Caused by error in `1 + ""`: ! non-numeric argument to binary operator From 4b867321f8221a80730b9f04ace95962cf47539d Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 14:27:11 -0500 Subject: [PATCH 07/12] Make all old deprecations always warn --- NEWS.md | 4 ++++ R/colwise-funs.R | 1 + R/count-tally.R | 4 ++-- R/deprec-combine.R | 2 +- R/deprec-dbi.R | 9 ++++++--- R/deprec-lazyeval.R | 11 ++++++----- R/deprec-src-local.r | 2 +- R/deprec-tibble.R | 6 +++--- R/group-by.r | 4 ++-- R/group_data.R | 8 +++++--- R/group_map.R | 6 +++--- R/group_split.R | 6 +++--- R/select-helpers.R | 3 ++- 13 files changed, 39 insertions(+), 27 deletions(-) diff --git a/NEWS.md b/NEWS.md index 700164498a..e79f044a55 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,10 @@ * `location()` and `changes()`, deprecated in 1.0.0, are now defunct (#6387). +* All other functions deprecated in 1.0.0 and earlier now warn every time you + use them (#6387). They are likely to be made defunct in the next major + version (but not before mid 2024). + * `nth()`, `first()`, and `last()` have gained an `na_rm` argument since they are summary functions (#6242, with contributions from @tnederlof). diff --git a/R/colwise-funs.R b/R/colwise-funs.R index 9520084ca2..f7a6d74dac 100644 --- a/R/colwise-funs.R +++ b/R/colwise-funs.R @@ -32,6 +32,7 @@ as_fun_list <- function(.funs, .env, ..., .caller, .caller_arg = "...", error_ca lifecycle::deprecate_warn( "0.8.3", what, details = "Please use a one-sided formula, a function, or a function name.", + always = TRUE, env = .env ) .x <- new_formula(NULL, quo_squash(.x), quo_get_env(.x)) diff --git a/R/count-tally.R b/R/count-tally.R index a0ddf4418d..62594f58a6 100644 --- a/R/count-tally.R +++ b/R/count-tally.R @@ -112,7 +112,7 @@ add_count <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = depr #' @export add_count.default <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated()) { if (!missing(.drop)) { - lifecycle::deprecate_warn("1.0.0", "add_count(.drop = )") + lifecycle::deprecate_warn("1.0.0", "add_count(.drop = )", always = TRUE) } if (!missing(...)) { @@ -127,7 +127,7 @@ add_count.default <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .dro #' @export add_count.data.frame <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated()) { if (!missing(.drop)) { - lifecycle::deprecate_warn("1.0.0", "add_count(.drop = )") + lifecycle::deprecate_warn("1.0.0", "add_count(.drop = )", always = TRUE) } if (!missing(...)) { diff --git a/R/deprec-combine.R b/R/deprec-combine.R index 0d4e451ffb..3580dafff6 100644 --- a/R/deprec-combine.R +++ b/R/deprec-combine.R @@ -22,7 +22,7 @@ #' # -> #' vctrs::vec_c(!!!list(f1, f2)) combine <- function(...) { - lifecycle::deprecate_warn("1.0.0", "combine()", "vctrs::vec_c()") + lifecycle::deprecate_warn("1.0.0", "combine()", "vctrs::vec_c()", always = TRUE) args <- list2(...) if (length(args) == 1 && is.list(args[[1]])) { diff --git a/R/deprec-dbi.R b/R/deprec-dbi.R index 0bbba82dd6..28eb26b0e4 100644 --- a/R/deprec-dbi.R +++ b/R/deprec-dbi.R @@ -42,7 +42,8 @@ src_mysql <- function(dbname, host = NULL, port = 0L, username = "root", check_installed("RMySQL", "to connect to MySQL/MariaDB.") lifecycle::deprecate_warn( "1.0.0", "dplyr::src_mysql()", - details = "Please use `tbl()` directly with a database connection" + details = "Please use `tbl()` directly with a database connection", + always = TRUE ) con <- DBI::dbConnect( @@ -65,7 +66,8 @@ src_postgres <- function(dbname = NULL, host = NULL, port = NULL, check_installed("RPostgreSQL", "to connect to PostgreSQL.") lifecycle::deprecate_warn( "1.0.0", "dplyr::src_postgres()", - details = "Please use `tbl()` directly with a database connection" + details = "Please use `tbl()` directly with a database connection", + always = TRUE ) in_travis <- identical(Sys.getenv("TRAVIS"), "true") @@ -97,7 +99,8 @@ src_sqlite <- function(path, create = FALSE) { check_dbplyr() lifecycle::deprecate_warn( "1.0.0", "dplyr::src_sqlite()", - details = "Please use `tbl()` directly with a database connection" + details = "Please use `tbl()` directly with a database connection", + always = TRUE ) if (!create && !file.exists(path)) { diff --git a/R/deprec-lazyeval.R b/R/deprec-lazyeval.R index e45098307a..2d2e4a7247 100644 --- a/R/deprec-lazyeval.R +++ b/R/deprec-lazyeval.R @@ -27,7 +27,8 @@ NULL lazy_deprec <- function(fun, hint = TRUE) { lifecycle::deprecate_warn("0.7.0", paste0(fun, "_()"), paste0(fun, "()"), - details = if (hint) "See vignette('programming') for more help" + details = if (hint) "See vignette('programming') for more help", + always = TRUE ) } @@ -268,7 +269,7 @@ rename_.grouped_df <- function(.data, ..., .dots = list()) { #' @export #' @rdname se-deprecated rename_vars_ <- function(vars, args) { - lifecycle::deprecate_warn("0.7.0", "rename_vars_()", "tidyselect::vars_rename()") + lifecycle::deprecate_warn("0.7.0", "rename_vars_()", "tidyselect::vars_rename()", always = TRUE) args <- compat_lazy_dots(args, caller_env()) tidyselect::vars_rename(vars, !!!args) } @@ -296,7 +297,7 @@ select_.grouped_df <- function(.data, ..., .dots = list()) { #' include/exclude. #' @export select_vars_ <- function(vars, args, include = chr(), exclude = chr()) { - lifecycle::deprecate_warn("0.7.0", "select_vars_()", "tidyselect::vars_select()") + lifecycle::deprecate_warn("0.7.0", "select_vars_()", "tidyselect::vars_select()", always = TRUE) args <- compat_lazy_dots(args, caller_env()) tidyselect::vars_select(vars, !!!args, .include = include, .exclude = exclude) } @@ -355,7 +356,7 @@ summarise_each <- function(tbl, funs, ...) { #' @export #' @rdname summarise_each summarise_each_ <- function(tbl, funs, vars) { - lifecycle::deprecate_warn("0.7.0", "summarise_each_()", "across()") + lifecycle::deprecate_warn("0.7.0", "summarise_each_()", "across()", always = TRUE) if (is_empty(vars)) { vars <- tbl_nongroup_vars(tbl) @@ -385,7 +386,7 @@ mutate_each <- function(tbl, funs, ...) { #' @export #' @rdname summarise_each mutate_each_ <- function(tbl, funs, vars) { - lifecycle::deprecate_warn("0.7.0", "mutate_each_()", "across()") + lifecycle::deprecate_warn("0.7.0", "mutate_each_()", "across()", always = TRUE) if (is_empty(vars)) { vars <- tbl_nongroup_vars(tbl) diff --git a/R/deprec-src-local.r b/R/deprec-src-local.r index 7c7d99aefe..4a75d3e43d 100644 --- a/R/deprec-src-local.r +++ b/R/deprec-src-local.r @@ -10,7 +10,7 @@ #' @keywords internal #' @export src_local <- function(tbl, pkg = NULL, env = NULL) { - lifecycle::deprecate_warn("1.0.0", "src_local()") + lifecycle::deprecate_warn("1.0.0", "src_local()", always = TRUE) if (!xor(is.null(pkg), is.null(env))) { msg <- glue("Exactly one of `pkg` and `env` must be non-NULL, not {(!is.null(pkg)) + (!is.null(env))}.") diff --git a/R/deprec-tibble.R b/R/deprec-tibble.R index c4cc8e3840..a812d80256 100644 --- a/R/deprec-tibble.R +++ b/R/deprec-tibble.R @@ -7,7 +7,7 @@ #' @keywords internal #' @param data,x Object to coerce tbl_df <- function(data) { - lifecycle::deprecate_warn("1.0.0", "tbl_df()", "tibble::as_tibble()") + lifecycle::deprecate_warn("1.0.0", "tbl_df()", "tibble::as_tibble()", always = TRUE) # Works in tibble < 1.5.0 too, because .name_repair will be # swallowed by the ellipsis as_tibble(data, .name_repair = "check_unique") @@ -16,7 +16,7 @@ tbl_df <- function(data) { #' @export #' @rdname tbl_df as.tbl <- function(x, ...) { - lifecycle::deprecate_warn("1.0.0", "as.tbl()", "tibble::as_tibble()") + lifecycle::deprecate_warn("1.0.0", "as.tbl()", "tibble::as_tibble()", always = TRUE) UseMethod("as.tbl") } @@ -39,7 +39,7 @@ as.tbl.data.frame <- function(x, ...) { #' @keywords internal #' @export add_rownames <- function(df, var = "rowname") { - lifecycle::deprecate_warn("1.0.0", "add_rownames()", "tibble::rownames_to_column()") + lifecycle::deprecate_warn("1.0.0", "add_rownames()", "tibble::rownames_to_column()", always = TRUE) stopifnot(is.data.frame(df)) diff --git a/R/group-by.r b/R/group-by.r index a9603e0fbb..92f018a3d3 100644 --- a/R/group-by.r +++ b/R/group-by.r @@ -190,14 +190,14 @@ group_by_prepare <- function(.data, error_call = caller_env()) { if (!missing(add)) { - lifecycle::deprecate_warn("1.0.0", "group_by(add = )", "group_by(.add = )") + lifecycle::deprecate_warn("1.0.0", "group_by(add = )", "group_by(.add = )", always = TRUE) .add <- add } new_groups <- enquos(..., .ignore_empty = "all") if (!missing(.dots)) { # Used by dbplyr 1.4.2 so can't aggressively deprecate - lifecycle::deprecate_warn("1.0.0", "group_by(.dots = )") + lifecycle::deprecate_warn("1.0.0", "group_by(.dots = )", always = TRUE) new_groups <- c(new_groups, compat_lazy_dots(.dots, env = caller_env)) } diff --git a/R/group_data.R b/R/group_data.R index 44f246368d..5b64e4bc8b 100644 --- a/R/group_data.R +++ b/R/group_data.R @@ -91,7 +91,8 @@ group_keys.data.frame <- function(.tbl, ...) { if (dots_n(...) > 0) { lifecycle::deprecate_warn( "1.0.0", "group_keys(... = )", - details = "Please `group_by()` first" + details = "Please `group_by()` first", + always = TRUE ) .tbl <- group_by(.tbl, ...) } @@ -108,7 +109,7 @@ group_rows <- function(.data) { #' @rdname group_data group_indices <- function(.data, ...) { if (nargs() == 0) { - lifecycle::deprecate_warn("1.0.0", "group_indices()", "cur_group_id()") + lifecycle::deprecate_warn("1.0.0", "group_indices()", "cur_group_id()", always = TRUE) return(cur_group_id()) } @@ -119,7 +120,8 @@ group_indices.data.frame <- function(.data, ...) { if (dots_n(...) > 0) { lifecycle::deprecate_warn( "1.0.0", "group_indices(... = )", - details = "Please `group_by()` first" + details = "Please `group_by()` first", + always = TRUE ) .data <- group_by(.data, ...) } diff --git a/R/group_map.R b/R/group_map.R index 8c62ea3891..c09ba9c042 100644 --- a/R/group_map.R +++ b/R/group_map.R @@ -127,7 +127,7 @@ group_map <- function(.data, .f, ..., .keep = FALSE) { #' @export group_map.data.frame <- function(.data, .f, ..., .keep = FALSE, keep = deprecated()) { if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_map(keep = )", "group_map(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_map(keep = )", "group_map(.keep = )", always = TRUE) .keep <- keep } .f <- as_group_map_function(.f) @@ -159,7 +159,7 @@ group_modify <- function(.data, .f, ..., .keep = FALSE) { #' @export group_modify.data.frame <- function(.data, .f, ..., .keep = FALSE, keep = deprecated()) { if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_modify(keep = )", "group_modify(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_modify(keep = )", "group_modify(.keep = )", always = TRUE) .keep <- keep } .f <- as_group_map_function(.f) @@ -169,7 +169,7 @@ group_modify.data.frame <- function(.data, .f, ..., .keep = FALSE, keep = deprec #' @export group_modify.grouped_df <- function(.data, .f, ..., .keep = FALSE, keep = deprecated()) { if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_modify(keep = )", "group_modify(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_modify(keep = )", "group_modify(.keep = )", always = TRUE) .keep <- keep } tbl_group_vars <- group_vars(.data) diff --git a/R/group_split.R b/R/group_split.R index bbf126f636..c9a5b748e5 100644 --- a/R/group_split.R +++ b/R/group_split.R @@ -38,7 +38,7 @@ group_split <- function(.tbl, ..., .keep = TRUE) { #' @export group_split.data.frame <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) { if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )", always = TRUE) .keep <- keep } data <- group_by(.tbl, ...) @@ -51,7 +51,7 @@ group_split.rowwise_df <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) warn("... is ignored in group_split(), please use as_tibble() %>% group_split(...)") } if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )", always = TRUE) .keep <- keep } if (!missing(.keep)) { @@ -64,7 +64,7 @@ group_split.rowwise_df <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) #' @export group_split.grouped_df <- function(.tbl, ..., .keep = TRUE, keep = deprecated()) { if (!missing(keep)) { - lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )") + lifecycle::deprecate_warn("1.0.0", "group_split(keep = )", "group_split(.keep = )", always = TRUE) .keep <- keep } if (dots_n(...)) { diff --git a/R/select-helpers.R b/R/select-helpers.R index 2524c356d2..cc53555470 100644 --- a/R/select-helpers.R +++ b/R/select-helpers.R @@ -33,7 +33,8 @@ group_cols_legacy <- function(vars = NULL) { if (!is.null(vars)) { lifecycle::deprecate_warn( "1.0.0", "group_cols(vars = )", - details = "Use `data` with entire dataframe instead" + details = "Use `data` with entire dataframe instead", + always = TRUE ) } From 347efe45b2d5d5a952bc0036b99f1dddc493e45d Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 14:31:34 -0500 Subject: [PATCH 08/12] Deprecate progress_estimated --- NEWS.md | 2 ++ R/deprec-do.r | 5 +---- R/progress.R | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index e79f044a55..73b58195cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # dplyr (development version) +* `progress_estimate()` is deprecated for all uses (#6387). + * `funs()`, deprecated in 0.8.0, is now defunct (#6387). * `select_vars()`, `rename_vars()`, `select_var()` and `current_var()`, diff --git a/R/deprec-do.r b/R/deprec-do.r index 7e08300c66..d2ef9f820c 100644 --- a/R/deprec-do.r +++ b/R/deprec-do.r @@ -101,10 +101,7 @@ do.grouped_df <- function(.data, ...) { out <- replicate(m, vector("list", n), simplify = FALSE) names(out) <- names(args) - p <- rlang::with_options( - lifecycle_verbosity = "quiet", - progress_estimated(n * m, min_time = 2) - ) + p <- Progress$new(n * m, min_time = 2) for (`_i` in seq_len(n)) { for (j in seq_len(m)) { diff --git a/R/progress.R b/R/progress.R index bca5640257..17f2f4c5e8 100644 --- a/R/progress.R +++ b/R/progress.R @@ -42,7 +42,8 @@ #' for (i in 1:10) p$pause(0.5)$tick()$print() #' } progress_estimated <- function(n, min_time = 0) { - lifecycle::deprecate_soft("1.0.0", "dplyr::progress_estimated()") + # Before 1.1.0 was soft deprecated; so doesn't get always = TRUE until 1.2.0 + lifecycle::deprecate_warn("1.0.0", "dplyr::progress_estimated()") Progress$new(n, min_time = min_time) } From cc32c804202a9a5134840e0ce6c421f749864d79 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 15:46:11 -0500 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: Davis Vaughan --- R/defunct.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/defunct.r b/R/defunct.r index 5e0bfc3970..a7c52e8f95 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -109,7 +109,7 @@ eval_tbls2 <- function(tbls_x, tbls_y, op) { #' @export #' @rdname defunct location <- function(df) { - lifecycle::deprecate_stop("1.0.0", "location()", "lobst::ref()") + lifecycle::deprecate_stop("1.0.0", "location()", "lobstr::ref()") } #' @export From 680252a0e3dfd51242193c61146cc8d96b6082a9 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 15:48:52 -0500 Subject: [PATCH 10/12] Fix snapshot & re-run --- tests/testthat/_snaps/defunct.md | 8 ++++---- tests/testthat/test-defunct.r | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testthat/_snaps/defunct.md b/tests/testthat/_snaps/defunct.md index e93afda5fb..d132dbb729 100644 --- a/tests/testthat/_snaps/defunct.md +++ b/tests/testthat/_snaps/defunct.md @@ -52,10 +52,10 @@ ! `current_vars()` was deprecated in dplyr 0.8.4 and is now defunct. Please use `tidyselect::peek_vars()` instead. Code - bench_tbl() + bench_tbls() Condition - Error in `bench_tbl()`: - ! could not find function "bench_tbl" + Error: + ! `bench_tbls()` was deprecated in dplyr 1.0.0 and is now defunct. Code compare_tbls() Condition @@ -81,7 +81,7 @@ Condition Error: ! `location()` was deprecated in dplyr 1.0.0 and is now defunct. - Please use `lobst::ref()` instead. + Please use `lobstr::ref()` instead. Code changes() Condition diff --git a/tests/testthat/test-defunct.r b/tests/testthat/test-defunct.r index e9e1faf658..8d0faced50 100644 --- a/tests/testthat/test-defunct.r +++ b/tests/testthat/test-defunct.r @@ -11,7 +11,7 @@ test_that("generate informative errors", { select_var() current_vars() - bench_tbl() + bench_tbls() compare_tbls() compare_tbls2() eval_tbls() From 088752a560a50ad7f7c635577d55bd6b9043a013 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 15:51:34 -0500 Subject: [PATCH 11/12] Doc polishing --- R/defunct.r | 5 +++-- man/defunct.Rd | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/defunct.r b/R/defunct.r index a7c52e8f95..966a1a313f 100644 --- a/R/defunct.r +++ b/R/defunct.r @@ -3,8 +3,9 @@ #' @description #' `r lifecycle::badge("defunct")` #' -#' These function were all deprecated for at least two years and are now -#' defunct. Executing them to tell you which function to use instead. +#' These functions were deprecated for at least two years before being +#' made defunct. If there's a known replacement, calling the function +#' will tell you about it. #' #' @keywords internal #' @name defunct diff --git a/man/defunct.Rd b/man/defunct.Rd index 4c5663b473..573ba4c224 100644 --- a/man/defunct.Rd +++ b/man/defunct.Rd @@ -57,7 +57,8 @@ changes(x, y) \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} -These function were all deprecated for at least two years and are now -defunct. Executing them to tell you which function to use instead. +These functions were deprecated for at least two years before being +made defunct. If there's a known replacement, calling the function +will tell you about it. } \keyword{internal} From 32898c83201f47f99ddc8ac324e39fca3df5ea96 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 16 Aug 2022 15:53:55 -0500 Subject: [PATCH 12/12] Remove all_equal() from index --- _pkgdown.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index 7d11848fb6..734507e076 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -107,14 +107,6 @@ reference: - group_split - with_groups -- title: Questioning - desc: > - We have our doubts about questioning functions. We're not certain that - they're inadequate, or we don't have a good replacement in mind, but - these functions are at risk of removal in the future. - contents: - - all_equal - - title: Superseded desc: > Superseded functions have been replaced by new approaches that we believe