diff --git a/DESCRIPTION b/DESCRIPTION index e66547f..8af083c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: santoku Type: Package Title: A Versatile Cutting Tool -Version: 0.10.0.9000 +Version: 1.0.0 Authors@R: c( person(given = "David", diff --git a/NEWS.md b/NEWS.md index e3a6a86..020b227 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,13 @@ -# santoku (development version) +# santoku 1.0.0 +* santoku is now considered stable. * `chop_quantiles()` and `brk_quantiles()` gain a new `weights` argument, letting you chop by weighted quantiles using `Hmisc::wtd.quantile()`. * `brk_quantiles()` may now return singleton breaks, producing more accurate results when `x` has duplicate elements. +* Some deprecated functions have been removed, and the `raw` argument to + `lbl_*` functions now always gives a deprecation warning. + # santoku 0.10.0 diff --git a/R/breaks.R b/R/breaks.R index 9d0e9f2..a91b503 100644 --- a/R/breaks.R +++ b/R/breaks.R @@ -78,7 +78,7 @@ brk_equally <- function (groups) { #' @importFrom lifecycle deprecated brk_mean_sd <- function (sds = 1:3, sd = deprecated()) { if (lifecycle::is_present(sd)) { - lifecycle::deprecate_soft( + lifecycle::deprecate_warn( when = "0.7.0", what = "brk_mean_sd(sd)", with = "brk_mean_sd(sds = 'vector of sds')" diff --git a/R/chop.R b/R/chop.R index fd39f67..5a9a91a 100644 --- a/R/chop.R +++ b/R/chop.R @@ -399,7 +399,6 @@ chop_mean_sd <- function ( } - #' Chop using pretty breakpoints #' #' `chop_pretty()` uses [base::pretty()] to calculate breakpoints diff --git a/R/labels.R b/R/labels.R index d887422..a6edb5e 100644 --- a/R/labels.R +++ b/R/labels.R @@ -75,7 +75,7 @@ lbl_intervals <- function ( raw = FALSE ) { if (! isFALSE(raw)) { - lifecycle::deprecate_soft("0.9.0", "lbl_intervals(raw)", "chop(raw)") + lifecycle::deprecate_warn("0.9.0", "lbl_intervals(raw)", "chop(raw)") } interval_glue <- "{ifelse(l_closed, '[', '(')}{l}, {r}{ifelse(r_closed, ']', ')')}" lbl_glue(label = interval_glue, single = single, fmt = fmt, first = first, @@ -116,7 +116,7 @@ lbl_dash <- function ( raw = FALSE ) { if (! isFALSE(raw)) { - lifecycle::deprecate_soft("0.9.0", "lbl_dash(raw)", "chop(raw)") + lifecycle::deprecate_warn("0.9.0", "lbl_dash(raw)", "chop(raw)") } label_glue <- paste0("{l}", symbol, "{r}") @@ -147,7 +147,7 @@ lbl_midpoints <- function ( raw = FALSE ) { if (! isFALSE(raw)) { - lifecycle::deprecate_soft("0.9.0", "lbl_midpoints(raw)", "chop(raw)") + lifecycle::deprecate_warn("0.9.0", "lbl_midpoints(raw)", "chop(raw)") } RAW <- raw # avoid "recursive default argument reference" @@ -229,7 +229,7 @@ lbl_glue <- function ( ) if (! isFALSE(raw)) { - lifecycle::deprecate_soft("0.9.0", "lbl_glue(raw)", "chop(raw)") + lifecycle::deprecate_warn("0.9.0", "lbl_glue(raw)", "chop(raw)") } RAW <- raw # avoid "recursive default argument reference" @@ -314,7 +314,8 @@ lbl_glue <- function ( #' This is useful when the left endpoint unambiguously indicates the #' interval. In other cases it may give errors due to duplicate labels. #' -#' `lbl_endpoint()` is `r lifecycle::badge("deprecated")`. Do not use it. +#' `lbl_endpoint()` is `r lifecycle::badge("defunct")` and gives an +#' error since santoku 1.0.0. #' #' @inherit label-doc #' @inherit first-last-doc @@ -351,7 +352,7 @@ lbl_endpoints <- function ( assert_that(is.flag(left)) if (! isFALSE(raw)) { - lifecycle::deprecate_soft("0.9.0", "lbl_endpoints(raw)", "chop(raw)") + lifecycle::deprecate_warn("0.9.0", "lbl_endpoints(raw)", "chop(raw)") } label <- if (left) "{l}" else "{r}" @@ -367,9 +368,8 @@ lbl_endpoint <- function ( raw = FALSE, left = TRUE ) { - lifecycle::deprecate_warn(when = "0.8.0", what = "lbl_endpoint()", + lifecycle::deprecate_stop(when = "0.8.0", what = "lbl_endpoint()", with = "lbl_endpoints()") - lbl_endpoints(fmt = fmt, raw = raw, left = left) } @@ -549,17 +549,14 @@ lbl_seq <- function(start = "a") { } -#' Label chopped intervals in a user-defined sequence +#' Defunct: label chopped intervals in a user-defined sequence #' -#' `r lifecycle::badge("deprecated")` +#' `r lifecycle::badge("defunct")` #' -#' `lbl_manual()` is deprecated because it is little used and is not closely -#' related to the rest of the package. It also risks mislabelling intervals, e.g. -#' if intervals are extended. -#' -#' `lbl_manual()` uses an arbitrary sequence to label -#' intervals. If the sequence is too short, it will be pasted with itself and -#' repeated. +#' `lbl_manual()` is defunct since santoku 1.0.0. It is little used and is not +#' closely related to the rest of the package. It also risks mislabelling +#' intervals, e.g. if intervals are extended. Use of `lbl_manual()` will give +#' an error. #' #' @param sequence A character vector of labels. #' @inherit label-doc @@ -571,22 +568,12 @@ lbl_seq <- function(start = "a") { #' @keywords internal #' #' @examples +#' \dontrun{ #' chop(1:10, c(2, 5, 8), lbl_manual(c("w", "x", "y", "z"))) #' # -> #' chop(1:10, c(2, 5, 8), labels = c("w", "x", "y", "z")) +#' } lbl_manual <- function (sequence, fmt = "%s") { - lifecycle::deprecate_warn("0.9.0", "lbl_manual()", + lifecycle::deprecate_stop("0.9.0", "lbl_manual()", details = "Just specify `labels = sequence` instead.") - assert_that(is_format(fmt)) - - if (anyDuplicated(sequence) > 0L) stop("`sequence` contains duplicate items") - function (breaks, raw = NULL) { - ls <- sequence - latest <- ls - while (length(breaks) - 1 > length(ls)) { - latest <- paste0(latest, sequence) - ls <- c(ls, latest) - } - apply_format(fmt, ls[seq(1L, length(breaks) - 1)]) - } } \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index 8b6b9ec..1154950 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,7 +18,7 @@ knitr::opts_chunk$set( [![CRAN status](https://www.r-pkg.org/badges/version/santoku)](https://CRAN.R-project.org/package=santoku) -[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) +[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![CRAN Downloads Per Month](http://cranlogs.r-pkg.org/badges/santoku)](https://CRAN.R-project.org/package=santoku) [![R-universe](https://hughjonesd.r-universe.dev/badges/santoku)](https://hughjonesd.r-universe.dev/santoku) [![R-CMD-check](https://github.com/hughjonesd/santoku/workflows/R-CMD-check/badge.svg)](https://github.com/hughjonesd/santoku/actions) diff --git a/README.md b/README.md index 2290cd9..268a2cc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![CRAN status](https://www.r-pkg.org/badges/version/santoku)](https://CRAN.R-project.org/package=santoku) [![Lifecycle: -experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) +stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![CRAN Downloads Per Month](http://cranlogs.r-pkg.org/badges/santoku)](https://CRAN.R-project.org/package=santoku) [![R-universe](https://hughjonesd.r-universe.dev/badges/santoku)](https://hughjonesd.r-universe.dev/santoku) @@ -113,10 +113,10 @@ Chop into fixed-width intervals: ``` r chop_width(runif(10), 0.1) -#> [1] [0.1399, 0.2399) [0.5399, 0.6399) [0.5399, 0.6399) [0.5399, 0.6399) -#> [5] [0.6399, 0.7399) [0.3399, 0.4399) [0.8399, 0.9399] [0.8399, 0.9399] -#> [9] [0.5399, 0.6399) [0.1399, 0.2399) -#> 5 Levels: [0.1399, 0.2399) [0.3399, 0.4399) ... [0.8399, 0.9399] +#> [1] [0.1068, 0.2068) [0.6068, 0.7068) [0.9068, 1.007] [0.006763, 0.1068) +#> [5] [0.9068, 1.007] [0.3068, 0.4068) [0.6068, 0.7068) [0.1068, 0.2068) +#> [9] [0.4068, 0.5068) [0.5068, 0.6068) +#> 7 Levels: [0.006763, 0.1068) [0.1068, 0.2068) ... [0.9068, 1.007] ``` Or into fixed-size groups: diff --git a/man/lbl_endpoints.Rd b/man/lbl_endpoints.Rd index 0f27e72..bd20911 100644 --- a/man/lbl_endpoints.Rd +++ b/man/lbl_endpoints.Rd @@ -43,7 +43,8 @@ This is useful when the left endpoint unambiguously indicates the interval. In other cases it may give errors due to duplicate labels. } \details{ -\code{lbl_endpoint()} is \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}. Do not use it. +\code{lbl_endpoint()} is \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} and gives an +error since santoku 1.0.0. } \section{Formatting endpoints}{ diff --git a/man/lbl_manual.Rd b/man/lbl_manual.Rd index 722f054..274d5aa 100644 --- a/man/lbl_manual.Rd +++ b/man/lbl_manual.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/labels.R \name{lbl_manual} \alias{lbl_manual} -\title{Label chopped intervals in a user-defined sequence} +\title{Defunct: label chopped intervals in a user-defined sequence} \usage{ lbl_manual(sequence, fmt = "\%s") } @@ -15,16 +15,13 @@ lbl_manual(sequence, fmt = "\%s") A function that creates a vector of labels. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#defunct}{\figure{lifecycle-defunct.svg}{options: alt='[Defunct]'}}}{\strong{[Defunct]}} } \details{ -\code{lbl_manual()} is deprecated because it is little used and is not closely -related to the rest of the package. It also risks mislabelling intervals, e.g. -if intervals are extended. - -\code{lbl_manual()} uses an arbitrary sequence to label -intervals. If the sequence is too short, it will be pasted with itself and -repeated. +\code{lbl_manual()} is defunct since santoku 1.0.0. It is little used and is not +closely related to the rest of the package. It also risks mislabelling +intervals, e.g. if intervals are extended. Use of \code{lbl_manual()} will give +an error. } \section{Formatting endpoints}{ @@ -42,10 +39,12 @@ to use functions from the \code{{scales}} package, e.g. \code{\link[scales:label } \examples{ +\dontrun{ chop(1:10, c(2, 5, 8), lbl_manual(c("w", "x", "y", "z"))) # -> chop(1:10, c(2, 5, 8), labels = c("w", "x", "y", "z")) } +} \seealso{ Other labelling functions: \code{\link{lbl_dash}()}, diff --git a/tests/testthat/test-labels.R b/tests/testthat/test-labels.R index ce06e18..386d794 100644 --- a/tests/testthat/test-labels.R +++ b/tests/testthat/test-labels.R @@ -2,15 +2,9 @@ brackets <- function (x) paste0("(", x, ")") -test_that("lbl_manual", { - brk <- brk_res(brk_manual(1:3, rep(TRUE, 3))) - - lifecycle::expect_deprecated(lbl_manual(letters)) - - withr::local_options(lifecycle_verbosity = "quiet") - - expect_error(lbl_manual(c("a", "a"))) - expect_equivalent(lbl_manual(letters[1])(brk), c("a", "aa")) +test_that("lbl_manual and lbl_endpoint are defunct", { + lifecycle::expect_defunct(lbl_manual(letters)) + lifecycle::expect_defunct(lbl_endpoint()(lbrk)) }) @@ -196,8 +190,6 @@ test_that("lbl_endpoints arguments", { lbl_endpoints(fmt = list(nsmall = 2, decimal.mark = ","))(lbrk), c("1,00", "3,00") ) - - lifecycle::expect_deprecated(lbl_endpoint()(lbrk)) })