diff --git a/.Rbuildignore b/.Rbuildignore index 0f029765..e80e8c7f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,4 @@ ^\.github/workflows/R\.yaml$ ^\.github/workflows/pr-commands\.yaml$ ^CRAN-SUBMISSION$ +^LICENSE\.md$ diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 24aa0a3c..3ac34c82 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -1,25 +1,126 @@ -# Contributor Code of Conduct +# Contributor Covenant Code of Conduct -As contributors and maintainers of this project, we pledge to respect all people who -contribute through reporting issues, posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project a harassment-free experience for -everyone, regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. -Examples of unacceptable behavior by participants include the use of sexual language or -imagery, derogatory comments or personal attacks, trolling, public or private harassment, -insults, or other unprofessional conduct. +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. -Project maintainers have the right and responsibility to remove, edit, or reject comments, -commits, code, wiki edits, issues, and other contributions that are not aligned to this -Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed -from the project team. +## Our Standards -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by -opening an issue or contacting one or more of the project maintainers. +Examples of behavior that contributes to a positive environment for our +community include: -This Code of Conduct is adapted from the Contributor Covenant -(http://contributor-covenant.org), version 1.0.0, available at -http://contributor-covenant.org/version/1/0/0/ +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at codeofconduct@posit.co. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion]. + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at . + +[homepage]: https://www.contributor-covenant.org diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4efedd96..ee65ccb5 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -22,26 +22,27 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} # Use 3.6 to trigger usage of RTools35 - {os: windows-latest, r: '3.6'} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} - # Use older ubuntu to maximise backward compatibility - - {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-18.04, r: 'release'} - - {os: ubuntu-18.04, r: 'oldrel-1'} - - {os: ubuntu-18.04, r: 'oldrel-2'} - - {os: ubuntu-18.04, r: 'oldrel-3'} - - {os: ubuntu-18.04, r: 'oldrel-4'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 0b260216..ed7650c7 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -19,8 +19,10 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 @@ -39,7 +41,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@4.1.4 + uses: JamesIves/github-pages-deploy-action@v4.4.1 with: clean: false branch: gh-pages diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 97271eb2..71f335b3 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -14,7 +14,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: @@ -51,7 +51,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4b654182..27d45283 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -15,7 +15,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-r@v2 with: @@ -27,5 +27,24 @@ jobs: needs: coverage - name: Test coverage - run: covr::codecov(quiet = FALSE) + run: | + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/DESCRIPTION b/DESCRIPTION index 7c16c0f9..ae879c8d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,9 +2,11 @@ Package: scales Title: Scale Functions for Visualization Version: 1.2.1.9000 Authors@R: c( - person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), + person("Hadley", "Wickham", , "hadley@posit.co", role = c("aut")), + person("Thomas Lin", "Pedersen", , "thomasp85@posit.co", role = c("cre", "aut"), + comment = c(ORCID = "0000-0002-5147-4711")), person("Dana", "Seidel", role = "aut"), - person("RStudio", role = c("cph", "fnd")) + person("Posit, PBC", role = c("cph", "fnd")) ) Description: Graphical scales map data to aesthetics, and provide methods for automatically determining breaks and labels for axes and legends. @@ -12,9 +14,11 @@ License: MIT + file LICENSE URL: https://scales.r-lib.org, https://github.com/r-lib/scales BugReports: https://github.com/r-lib/scales/issues Depends: - R (>= 3.2) + R (>= 3.6) Imports: + cli, farver (>= 2.0.3), + glue, labeling, lifecycle, munsell (>= 0.5), @@ -32,8 +36,8 @@ Suggests: testthat (>= 3.0.0), waldo (>= 0.4.0) Config/Needs/website: tidyverse/tidytemplate +Config/testthat/edition: 3 Encoding: UTF-8 LazyLoad: yes Roxygen: list(markdown = TRUE, r6 = FALSE) -RoxygenNote: 7.2.1 -Config/testthat/edition: 3 +RoxygenNote: 7.2.3 diff --git a/LICENSE b/LICENSE index 267ea46f..5353308f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2010-2016 -COPYRIGHT HOLDER: Hadley Wickham +YEAR: 2023 +COPYRIGHT HOLDER: scales authors diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..86d1cefa --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2023 scales authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NAMESPACE b/NAMESPACE index 2e821ea1..4405d0ee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -169,6 +169,7 @@ export(yj_trans) export(zero_range) import(rlang) importFrom(R6,R6Class) +importFrom(glue,glue) importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,rect) diff --git a/R/bounds.r b/R/bounds.R similarity index 99% rename from R/bounds.r rename to R/bounds.R index e10f799f..b66059db 100644 --- a/R/bounds.r +++ b/R/bounds.R @@ -351,7 +351,7 @@ zero_range <- function(x, tol = 1000 * .Machine$double.eps) { if (length(x) == 1) { return(TRUE) } - if (length(x) != 2) stop("x must be length 1 or 2") + if (length(x) != 2) cli::cli_abort("{.arg x} must be length 1 or 2") if (any(is.na(x))) { return(NA) } diff --git a/R/breaks-retired.R b/R/breaks-retired.R index bd6bea03..31b864fe 100644 --- a/R/breaks-retired.R +++ b/R/breaks-retired.R @@ -92,9 +92,7 @@ cbreaks <- function(range, breaks = extended_breaks(), labels = scientific_forma breaks <- breaks(range) if (!is.function(labels)) { - stop("Labels can only be manually specified in conjunction with breaks", - call. = FALSE - ) + cli::cli_abort("{.arg labels} can only be manually specified in conjunction with {.arg breaks}") } } @@ -102,7 +100,7 @@ cbreaks <- function(range, breaks = extended_breaks(), labels = scientific_forma labels <- labels(breaks) } else { if (length(labels) != length(breaks)) { - stop("Labels and breaks must be same length") + cli::cli_abort("{.arg labels} and {.arg breaks} must be same length") } if (is.expression(labels)) { labels <- as.list(labels) diff --git a/R/breaks.r b/R/breaks.R similarity index 100% rename from R/breaks.r rename to R/breaks.R diff --git a/R/colour-manip.r b/R/colour-manip.R similarity index 97% rename from R/colour-manip.r rename to R/colour-manip.R index 7cb569c3..3ea479e9 100644 --- a/R/colour-manip.r +++ b/R/colour-manip.R @@ -53,7 +53,7 @@ muted <- function(colour, l = 30, c = 70) col2hcl(colour, l = l, c = c) alpha <- function(colour, alpha = NA) { if (length(colour) != length(alpha)) { if (length(colour) > 1 && length(alpha) > 1) { - stop("Only one of colour and alpha can be vectorised") + cli::cli_abort("Only one of {.arg colour} and {.arg alpha} can be vectorised") } if (length(colour) > 1) { diff --git a/R/colour-mapping.r b/R/colour-mapping.R similarity index 92% rename from R/colour-mapping.r rename to R/colour-mapping.R index ac6c6bad..76b82066 100644 --- a/R/colour-mapping.r +++ b/R/colour-mapping.R @@ -38,7 +38,7 @@ col_numeric <- function(palette, domain, na.color = "#808080", alpha = FALSE, re if (length(domain) > 0) { rng <- range(domain, na.rm = TRUE) if (!all(is.finite(rng))) { - stop("Wasn't able to determine range of domain") + cli::cli_abort("Wasn't able to determine range of {.arg domain}") } } @@ -53,7 +53,7 @@ col_numeric <- function(palette, domain, na.color = "#808080", alpha = FALSE, re rescaled <- rescale(x, from = rng) if (any(rescaled < 0 | rescaled > 1, na.rm = TRUE)) { - warning("Some values were outside the color scale and will be treated as NA", call. = FALSE) + cli::cli_warn("Some values were outside the color scale and will be treated as NA") } if (reverse) { @@ -74,7 +74,7 @@ withColorAttr <- function(type, args = list(), fun) { # bins is non-NULL. It may be a scalar value (# of breaks) or a set of breaks. getBins <- function(domain, x, bins, pretty) { if (is.null(domain) && is.null(x)) { - stop("Assertion failed: domain and x can't both be NULL") + cli::cli_abort("{.arg domain} and {.arg x} can't both be NULL") } # Hard-coded bins @@ -83,7 +83,10 @@ getBins <- function(domain, x, bins, pretty) { } if (bins < 2) { - stop("Invalid bins value of ", bins, "; bin count must be at least 2") + cli::cli_abort(c( + "Invalid {.arg bins} value ({bins})", + i = "bin count must be at least 2" + )) } if (pretty) { base::pretty(domain %||% x, n = bins) @@ -134,7 +137,7 @@ col_bin <- function(palette, domain, bins = 7, pretty = TRUE, binsToUse <- getBins(domain, x, bins, pretty) ints <- cut(x, binsToUse, labels = FALSE, include.lowest = TRUE, right = right) if (any(is.na(x) != is.na(ints))) { - warning("Some values were outside the color scale and will be treated as NA", call. = FALSE) + cli::cli_warn("Some values were outside the color scale and will be treated as NA") } colorFunc(ints) }) @@ -174,7 +177,7 @@ col_quantile <- function(palette, domain, n = 4, binsToUse <- safe_quantile(x, probs) ints <- cut(x, binsToUse, labels = FALSE, include.lowest = TRUE, right = right) if (any(is.na(x) != is.na(ints))) { - warning("Some values were outside the color scale and will be treated as NA", call. = FALSE) + cli::cli_warn("Some values were outside the color scale and will be treated as NA") } colorFunc(ints) }) @@ -184,11 +187,7 @@ safe_quantile <- function(x, probs) { bins <- stats::quantile(x, probs, na.rm = TRUE, names = FALSE) if (anyDuplicated(bins)) { bins <- unique(bins) - warning( - "Skewed data means we can only allocate ", length(bins), " unique colours ", - "not the " , length(probs) - 1, " requested", - call. = FALSE - ) + cli::cli_warn("Skewed data means we can only allocate {length(bins)} unique colours not the {length(probs) - 1} requested") } bins } @@ -240,7 +239,7 @@ col_factor <- function(palette, domain, levels = NULL, ordered = FALSE, } if (!is.null(levels) && anyDuplicated(levels)) { - warning("Duplicate levels detected", call. = FALSE) + cli::cli_warn("Duplicate levels detected") levels <- unique(levels) } lvls <- getLevels(domain, NULL, levels, ordered) @@ -257,12 +256,12 @@ col_factor <- function(palette, domain, levels = NULL, ordered = FALSE, origNa <- is.na(x) x <- match(as.character(x), lvls) if (any(is.na(x) != origNa)) { - warning("Some values were outside the color scale and will be treated as NA", call. = FALSE) + cli::cli_warn("Some values were outside the color scale and will be treated as NA") } scaled <- rescale(as.integer(x), from = c(1, length(lvls))) if (any(scaled < 0 | scaled > 1, na.rm = TRUE)) { - warning("Some values were outside the color scale and will be treated as NA", call. = FALSE) + cli::cli_warn("Some values were outside the color scale and will be treated as NA") } if (reverse) { scaled <- 1 - scaled @@ -383,7 +382,7 @@ filterRGB <- function(f) { } else if (is.matrix(results)) { farver::encode_colour(results, from = "rgb") } else { - stop("Unexpected result type ", class(x)[[1]]) + cli::cli_abort("Unexpected result type {.cls {class(x)}}") } } } diff --git a/R/colour-ramp.R b/R/colour-ramp.R index fa10a985..aa8decf8 100644 --- a/R/colour-ramp.R +++ b/R/colour-ramp.R @@ -34,7 +34,7 @@ #' show_col(ramp(seq(0, 1, length = 12))) colour_ramp <- function(colors, na.color = NA, alpha = TRUE) { if (length(colors) == 0) { - stop("Must provide at least one colour to create a colour ramp") + cli::cli_abort("Must provide at least one colour to create a colour ramp") } if (length(colors) == 1) { diff --git a/R/date-time.r b/R/date-time.R similarity index 100% rename from R/date-time.r rename to R/date-time.R diff --git a/R/documentation.r b/R/documentation.R similarity index 100% rename from R/documentation.r rename to R/documentation.R diff --git a/R/full-seq.r b/R/full-seq.R similarity index 100% rename from R/full-seq.r rename to R/full-seq.R diff --git a/R/label-bytes.R b/R/label-bytes.R index 7dd1818a..8fa805e6 100644 --- a/R/label-bytes.R +++ b/R/label-bytes.R @@ -13,7 +13,7 @@ #' * `auto_si` or `auto_binary` to automatically pick the most appropriate #' unit for each value. #' @inheritParams number_format -#' @param ... Other arguments passed on to [number()] +#' @inheritDotParams number #' @return A labeller function that takes a numeric vector of breaks and #' returns a character vector of labels. #' @export @@ -37,7 +37,9 @@ #' labels = label_bytes("auto_binary") #' ) label_bytes <- function(units = "auto_si", accuracy = 1, scale = 1, ...) { - stopifnot(is.character(units), length(units) == 1) + if (!(is.character(units) && length(units) == 1)) { + cli::cli_abort("{.arg units} must be a scalar string") + } force_all(accuracy, ...) function(x) { @@ -56,7 +58,7 @@ label_bytes <- function(units = "auto_si", accuracy = 1, scale = 1, ...) { base <- 1024 power <- powers[[match(units, bin_units)]] } else { - stop("'", units, "' is not a valid unit", call. = FALSE) + cli::cli_abort("{.val {units}} is not a valid unit") } suffix <- paste0(" ", units) diff --git a/R/label-date.R b/R/label-date.R index e7db2cc6..af89dc20 100644 --- a/R/label-date.R +++ b/R/label-date.R @@ -109,11 +109,7 @@ label_time <- function(format = "%H:%M:%S", tz = "UTC", locale = NULL) { } else if (inherits(x, "difftime")) { format(as.POSIXct(x), format = format, tz = tz) } else { - stop( - "time_format can't be used with objects of class ", paste(class(x), collapse = "/"), - ".", - call. = FALSE - ) + cli::cli_abort("{.fun label_time} can't be used with an object of class {.cls {class(x)}}") } } } diff --git a/R/label-dollar.R b/R/label-dollar.R index e02c20f4..25485eaa 100644 --- a/R/label-dollar.R +++ b/R/label-dollar.R @@ -11,7 +11,7 @@ #' @param prefix,suffix Symbols to display before and after value. #' @param negative_parens `r lifecycle::badge("deprecated")` Use #' `style_negative = "parens"` instead. -#' @param ... Other arguments passed on to [base::format()]. +#' @inheritDotParams number #' @export #' @family labels for continuous scales #' @examples diff --git a/R/label-number-si.R b/R/label-number-si.R index 1e743763..087b5829 100644 --- a/R/label-number-si.R +++ b/R/label-number-si.R @@ -15,6 +15,7 @@ #' @param scale A scaling factor: `x` will be multiplied by `scale` before #' formatting. This is useful if the underlying data is already using an SI #' prefix. +#' @inheritDotParams label_number #' @export #' @family labels for continuous scales #' @family labels for log scales diff --git a/R/label-number.r b/R/label-number.R similarity index 98% rename from R/label-number.r rename to R/label-number.R index 0d347a14..0e8e1a2e 100644 --- a/R/label-number.r +++ b/R/label-number.R @@ -321,14 +321,14 @@ precision <- function(x) { scale_cut <- function(x, breaks, scale = 1, accuracy = NULL, suffix = "") { if (!is.numeric(breaks) || is.null(names(breaks))) { - abort("`scale_cut` must be a named numeric vector") + cli::cli_abort("{.arg scale_cut} must be a named numeric vector") } breaks <- sort(breaks, na.last = TRUE) if (any(is.na(breaks))) { - abort("`scale_cut` values must not be missing") + cli::cli_abort("{.arg scale_cut} values must not be missing") } if (!identical(breaks[[1]], 0) && !identical(breaks[[1]], 0L)) { - abort("Smallest value of `scales_cut` must be zero") + cli::cli_abort("Smallest value of {.arg scales_cut} must be zero") } break_suffix <- as.character(cut( diff --git a/R/label-ordinal.R b/R/label-ordinal.R index 1a86858f..b9de36f4 100644 --- a/R/label-ordinal.R +++ b/R/label-ordinal.R @@ -9,7 +9,7 @@ #' Name gives suffix, and value specifies which numbers to match. #' @param gender Masculin or feminin gender for French ordinal. #' @param plural Plural or singular for French ordinal. -#' @param ... Other arguments passed on to [base::format()]. +#' @inheritDotParams number #' @export #' @family labels for continuous scales #' @examples diff --git a/R/label-percent.R b/R/label-percent.R index fdc64eb7..5e482d31 100644 --- a/R/label-percent.R +++ b/R/label-percent.R @@ -1,6 +1,7 @@ #' Label percentages (2.5%, 50%, etc) #' #' @inherit label_number return params +#' @inheritDotParams label_number #' @export #' @family labels for continuous scales #' @examples diff --git a/R/label-pvalue.R b/R/label-pvalue.R index 8de008b7..2564daf0 100644 --- a/R/label-pvalue.R +++ b/R/label-pvalue.R @@ -64,7 +64,7 @@ pvalue <- function(x, } } else { if (!is.character(prefix) || length(prefix) != 3) { - stop("`prefix` must be a length 3 character vector", call. = FALSE) + cli::cli_abort("{.arg prefix} must be a length 3 character vector") } } diff --git a/R/labels-retired.R b/R/labels-retired.R index 41d37036..be1e2fe6 100644 --- a/R/labels-retired.R +++ b/R/labels-retired.R @@ -51,18 +51,15 @@ number_bytes <- function(x, symbol = "auto", units = c("binary", "si"), accuracy validate_byte_symbol <- function(symbol, symbols, default = "auto") { if (length(symbol) != 1) { - n <- length(symbol) - stop("`symbol` must have length 1, not length ", n, ".", call. = FALSE) + cli::cli_abort("{.arg symbol} must have length 1, not length {length(symbol)}") } valid_symbols <- c(default, symbols) if (!(symbol %in% valid_symbols)) { - warning( - "`symbol` must be one of: '", paste0(valid_symbols, collapse = "', '"), - "'; not '", symbol, "'.\n", - "Defaulting to '", default, "'.", - call. = FALSE - ) + cli::cli_warn(c( + "{.arg symbol} must be one of {.or {.or {valid_symbols}}}", + i = "The provided value ({.val {symbol}}) will be changed to the default ({.val {default}})" + )) symbol <- default } diff --git a/R/offset-by.r b/R/offset-by.R similarity index 100% rename from R/offset-by.r rename to R/offset-by.R diff --git a/R/pal-area.r b/R/pal-area.R similarity index 100% rename from R/pal-area.r rename to R/pal-area.R diff --git a/R/pal-brewer.r b/R/pal-brewer.R similarity index 97% rename from R/pal-brewer.r rename to R/pal-brewer.R index d62a5e21..72c5b358 100644 --- a/R/pal-brewer.r +++ b/R/pal-brewer.R @@ -45,7 +45,7 @@ brewer_pal <- function(type = "seq", palette = 1, direction = 1) { pal_name <- function(palette, type) { if (is.character(palette)) { if (!palette %in% unlist(brewer)) { - warning("Unknown palette ", palette) + cli::cli_warn("Unknown palette: {.val {palette}}") palette <- "Greens" } return(palette) diff --git a/R/pal-dichromat.r b/R/pal-dichromat.R similarity index 73% rename from R/pal-dichromat.r rename to R/pal-dichromat.R index e28c8591..65ebe98b 100644 --- a/R/pal-dichromat.r +++ b/R/pal-dichromat.R @@ -13,17 +13,10 @@ #' show_col(gradient_n_pal(cols)(seq(0, 1, length.out = 30))) #' } dichromat_pal <- function(name) { - if (!requireNamespace("dichromat", quietly = TRUE)) { - stop("Package dichromat must be installed for this function to work. Please install it.", - call. = FALSE - ) - } + check_installed("dichromat") if (!any(name == names(dichromat::colorschemes))) { - stop("Palette name must be one of ", - paste0(names(dichromat::colorschemes), collapse = ", "), - call. = FALSE - ) + cli::cli_abort("Palette name must be one of {.or {.val {names(dichromat::colorschemes)}}}") } pal <- dichromat::colorschemes[[name]] diff --git a/R/pal-gradient.r b/R/pal-gradient.R similarity index 100% rename from R/pal-gradient.r rename to R/pal-gradient.R diff --git a/R/pal-grey.r b/R/pal-grey.R similarity index 100% rename from R/pal-grey.r rename to R/pal-grey.R diff --git a/R/pal-hue.r b/R/pal-hue.R similarity index 82% rename from R/pal-hue.r rename to R/pal-hue.R index 84265faf..5dcdb5aa 100644 --- a/R/pal-hue.r +++ b/R/pal-hue.R @@ -25,13 +25,13 @@ #' show_col(hue_pal(h = c(180, 270))(9)) #' show_col(hue_pal(h = c(270, 360))(9)) hue_pal <- function(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1) { - stopifnot(length(h) == 2) - stopifnot(length(c) == 1) - stopifnot(length(l) == 1) + if (length(h) != 2) cli::cli_abort("{.arg h} must have length 2") + if (length(l) != 1) cli::cli_abort("{.arg l} must have length 1") + if (length(c) != 1) cli::cli_abort("{.arg c} must have length 1") force_all(h, c, l, h.start, direction) function(n) { if (n == 0) { - stop("Must request at least one colour from a hue palette.", call. = FALSE) + cli::cli_abort("Must request at least one colour from a hue palette.") } if ((diff(h) %% 360) < 1) { diff --git a/R/pal-identity.r b/R/pal-identity.R similarity index 100% rename from R/pal-identity.r rename to R/pal-identity.R diff --git a/R/pal-linetype.r b/R/pal-linetype.R similarity index 100% rename from R/pal-linetype.r rename to R/pal-linetype.R diff --git a/R/pal-manual.r b/R/pal-manual.R similarity index 64% rename from R/pal-manual.r rename to R/pal-manual.R index 7a0a9aee..8a4bef85 100644 --- a/R/pal-manual.r +++ b/R/pal-manual.R @@ -7,10 +7,7 @@ manual_pal <- function(values) { function(n) { n_values <- length(values) if (n > n_values) { - warning("This manual palette can handle a maximum of ", n_values, - " values. You have supplied ", n, ".", - call. = FALSE - ) + cli::cli_warn("This manual palette can handle a maximum of {n_values} values. You have supplied {n}") } unname(values[seq_len(n)]) } diff --git a/R/pal-rescale.r b/R/pal-rescale.R similarity index 100% rename from R/pal-rescale.r rename to R/pal-rescale.R diff --git a/R/pal-shape.R b/R/pal-shape.R new file mode 100644 index 00000000..b0d9d76f --- /dev/null +++ b/R/pal-shape.R @@ -0,0 +1,21 @@ +#' Shape palette (discrete) +#' +#' @param solid should shapes be solid or not? +#' @export +shape_pal <- function(solid = TRUE) { + force(solid) + function(n) { + if (n > 6) { + cli::cli_warn(c( + "The shape palette can deal with a maximum of 6 discrete values because more than 6 becomes difficult to discriminate", + i = "you have requested {n} values. Consider specifying shapes manually if you need that many have them." + )) + } + + if (solid) { + c(16, 17, 15, 3, 7, 8)[seq_len(n)] + } else { + c(1, 2, 0, 3, 7, 8)[seq_len(n)] + } + } +} diff --git a/R/pal-shape.r b/R/pal-shape.r deleted file mode 100644 index 4215a6b0..00000000 --- a/R/pal-shape.r +++ /dev/null @@ -1,24 +0,0 @@ -#' Shape palette (discrete) -#' -#' @param solid should shapes be solid or not? -#' @export -shape_pal <- function(solid = TRUE) { - force(solid) - function(n) { - if (n > 6) { - msg <- paste("The shape palette can deal with a maximum of 6 discrete ", - "values because more than 6 becomes difficult to discriminate; ", - "you have ", n, ". Consider specifying shapes manually if you ", - "must have them.", - sep = "" - ) - warning(paste(strwrap(msg), collapse = "\n"), call. = FALSE) - } - - if (solid) { - c(16, 17, 15, 3, 7, 8)[seq_len(n)] - } else { - c(1, 2, 0, 3, 7, 8)[seq_len(n)] - } - } -} diff --git a/R/pal-viridis.r b/R/pal-viridis.R similarity index 100% rename from R/pal-viridis.r rename to R/pal-viridis.R diff --git a/R/range.r b/R/range.R similarity index 100% rename from R/range.r rename to R/range.R diff --git a/R/round-any.r b/R/round-any.R similarity index 100% rename from R/round-any.r rename to R/round-any.R diff --git a/R/scale-continuous.r b/R/scale-continuous.R similarity index 92% rename from R/scale-continuous.r rename to R/scale-continuous.R index 5ba6eb1a..8ad1cfb1 100644 --- a/R/scale-continuous.r +++ b/R/scale-continuous.R @@ -24,7 +24,7 @@ #' col = cscale(hp, seq_gradient_pal("grey80", "black")) #' )) cscale <- function(x, palette, na.value = NA_real_, trans = identity_trans()) { - stopifnot(is.trans(trans)) + if (!is.trans(trans)) cli::cli_abort("{.arg trans} must be a {.cls trans} object") x <- trans$transform(x) limits <- train_continuous(x) @@ -43,7 +43,7 @@ train_continuous <- function(new, existing = NULL) { } if (is.factor(new) || !typeof(new) %in% c("integer", "double")) { - stop("Discrete value supplied to continuous scale", call. = FALSE) + cli::cli_abort("Discrete value supplied to a continuous scale") } suppressWarnings(range(existing, new, na.rm = TRUE, finite = TRUE)) diff --git a/R/scale-discrete.r b/R/scale-discrete.R similarity index 96% rename from R/scale-discrete.r rename to R/scale-discrete.R index 147c537a..9c949e7b 100644 --- a/R/scale-discrete.r +++ b/R/scale-discrete.R @@ -31,7 +31,7 @@ train_discrete <- function(new, existing = NULL, drop = FALSE, na.rm = FALSE) { } if (!is.discrete(new)) { - stop("Continuous value supplied to discrete scale", call. = FALSE) + cli::cli_abort("Continuous value supplied to a discrete scale") } discrete_range(existing, new, drop = drop, na.rm = na.rm) } diff --git a/R/scales-package.R b/R/scales-package.R index 291b4cf8..7c1cd8d5 100644 --- a/R/scales-package.R +++ b/R/scales-package.R @@ -6,6 +6,7 @@ # The following block is used by usethis to automatically manage # roxygen namespace tags. Modify with care! ## usethis namespace: start +#' @importFrom glue glue #' @importFrom lifecycle deprecate_soft #' @importFrom lifecycle deprecated ## usethis namespace: end diff --git a/R/trans-compose.R b/R/trans-compose.R index c2596da5..26b85da2 100644 --- a/R/trans-compose.R +++ b/R/trans-compose.R @@ -13,7 +13,7 @@ compose_trans <- function(...) { trans_list <- lapply(list2(...), as.trans) if (length(trans_list) == 0) { - abort("Must include at least 1 transformer to compose") + cli::cli_abort("{.fun compose_trans} must include at least 1 transformer to compose") } # Resolve domains @@ -21,7 +21,7 @@ compose_trans <- function(...) { domain <- compose_fwd(trans_list[[1]]$domain, trans_list[-1]) ) if (any(is.na(domain))) { - abort("Sequence of transformations yields invalid domain") + cli::cli_abort("Sequence of transformations yields invalid domain") } domain <- range(domain) diff --git a/R/trans-date.r b/R/trans-date.R similarity index 91% rename from R/trans-date.r rename to R/trans-date.R index 904bdefd..51424b36 100644 --- a/R/trans-date.r +++ b/R/trans-date.R @@ -19,9 +19,7 @@ date_trans <- function() { to_date <- function(x) structure(x, class = "Date") from_date <- function(x) { if (!inherits(x, "Date")) { - stop("Invalid input: date_trans works with objects of class Date only", - call. = FALSE - ) + cli::cli_abort("{.fun date_trans} works with objects of class {.cls Date} only") } structure(as.numeric(x), names = names(x)) } @@ -45,10 +43,7 @@ time_trans <- function(tz = NULL) { from_time <- function(x) { if (!inherits(x, "POSIXct")) { - stop("Invalid input: time_trans works with objects of class ", - "POSIXct only", - call. = FALSE - ) + cli::cli_abort("{.fun time_trans} works with objects of class {.cls POSIXct} only") } if (is.null(tz)) { tz <<- attr(as.POSIXlt(x), "tzone")[[1]] diff --git a/R/trans-numeric.r b/R/trans-numeric.R similarity index 95% rename from R/trans-numeric.r rename to R/trans-numeric.R index ef5099aa..b3152479 100644 --- a/R/trans-numeric.r +++ b/R/trans-numeric.R @@ -54,7 +54,7 @@ atanh_trans <- function() { #' #' John, J. A., & Draper, N. R. (1980). #' An alternative family of transformations. Applied Statistics, 190-197. -#' \url{http://www.jstor.org/stable/2986305} +#' \url{https://www.jstor.org/stable/2986305} #' @export #' @examples #' plot(boxcox_trans(-1), xlim = c(0, 10)) @@ -69,9 +69,10 @@ atanh_trans <- function() { boxcox_trans <- function(p, offset = 0) { trans <- function(x) { if (any((x + offset) < 0, na.rm = TRUE)) { - stop("boxcox_trans must be given only positive values. Consider using modulus_trans instead?", - call. = F - ) + cli::cli_abort(c( + "{.fun boxcox_trans} must be given only positive values", + i = "Consider using {.fun modulus_trans} instead?" + )) } if (abs(p) < 1e-07) { log(x + offset) @@ -128,7 +129,7 @@ modulus_trans <- function(p, offset = 1) { #' @param p Transformation exponent, \eqn{\lambda}. #' @references Yeo, I., & Johnson, R. (2000). #' A New Family of Power Transformations to Improve Normality or Symmetry. Biometrika, 87(4), 954-959. -#' \url{http://www.jstor.org/stable/2673623} +#' \url{https://www.jstor.org/stable/2673623} #' @export #' @examples #' plot(yj_trans(-1), xlim = c(-10, 10)) @@ -303,6 +304,10 @@ reciprocal_trans <- function() { #' Reverse transformation #' +#' reversing transformation works by multiplying the input with -1. This means +#' that reverse transformation cannot easily be composed with transformations +#' that require positive input unless the reversing is done as a final step. +#' #' @export #' @examples #' plot(reverse_trans(), xlim = c(-1, 1)) diff --git a/R/trans.r b/R/trans.R similarity index 97% rename from R/trans.r rename to R/trans.R index 93849a3b..65047db0 100644 --- a/R/trans.r +++ b/R/trans.R @@ -93,7 +93,7 @@ as.trans <- function(x, arg = deparse(substitute(x))) { compose_trans(!!!x) } } else { - abort(sprintf("`%s` must be a character vector or a transformer object", arg)) + cli::cli_abort(sprintf("{.arg %s} must be a character vector or a transformer object", arg)) } } diff --git a/R/utils.r b/R/utils.R similarity index 95% rename from R/utils.r rename to R/utils.R index 82b65ee9..e1928597 100644 --- a/R/utils.r +++ b/R/utils.R @@ -7,7 +7,7 @@ demo_ggplot <- function(x, scale_name, ...) { cat(paste0(deparse(call), "\n", collapse = "")) if (!requireNamespace("ggplot2", quietly = TRUE)) { - message("Skipping; ggplot2 not installed") + cli::cli_inform("Skipping; {.pkg ggplot2} not installed") return(invisible()) } diff --git a/README.Rmd b/README.Rmd index bd5d2e89..453ddfec 100644 --- a/README.Rmd +++ b/README.Rmd @@ -14,11 +14,11 @@ knitr::opts_chunk$set( ) ``` -# scales +# scales scales website [![CRAN status](https://www.r-pkg.org/badges/version/scales)](https://CRAN.R-project.org/package=scales) -[![R build status](https://github.com/r-lib/scales/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/scales/actions) +[![R-CMD-check](https://github.com/r-lib/scales/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/scales/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/r-lib/scales/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/scales?branch=main) @@ -32,8 +32,8 @@ One of the most difficult parts of any graphics package is scaling, converting f install.packages("scales") # Or the development version from Github: -# install.packages("devtools") -devtools::install_github("r-lib/scales") +# install.packages("pak") +pak::pak("r-lib/scales") ``` ## Usage diff --git a/README.md b/README.md index 094b7194..ba0e3504 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,13 @@ -# scales +# scales scales website [![CRAN status](https://www.r-pkg.org/badges/version/scales)](https://CRAN.R-project.org/package=scales) -[![R build -status](https://github.com/r-lib/scales/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/scales/actions) +[![R-CMD-check](https://github.com/r-lib/scales/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/scales/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/r-lib/scales/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/scales?branch=main) @@ -29,8 +28,8 @@ override the default breaks, labels, transformations and palettes. install.packages("scales") # Or the development version from Github: -# install.packages("devtools") -devtools::install_github("r-lib/scales") +# install.packages("pak") +pak::pak("r-lib/scales") ``` ## Usage @@ -67,6 +66,7 @@ txhousing %>% ![](man/figures/README-labels-1.png) ``` r + economics %>% filter(date < ymd("1970-01-01")) %>% ggplot(aes(date, pce)) + diff --git a/_pkgdown.yml b/_pkgdown.yml index f518b7f1..5767b20b 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -8,6 +8,9 @@ template: in_header: | +development: + mode: auto + reference: - title: Axis labels desc: > diff --git a/cran-comments.md b/cran-comments.md index 83224423..0ec3b070 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,6 +1,3 @@ -## R CMD check results -0 errors | 1 warnings | 0 notes - I'm seeing a warning from the JSTOR links, presumably because of their overactive robot detection software: URL: http://www.jstor.org/stable/2673623 diff --git a/man/Range.Rd b/man/Range.Rd index f6aa766e..cd834a0a 100644 --- a/man/Range.Rd +++ b/man/Range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/range.r +% Please edit documentation in R/range.R \name{Range} \alias{Range} \alias{DiscreteRange} diff --git a/man/alpha.Rd b/man/alpha.Rd index 8cc78b20..81b5b019 100644 --- a/man/alpha.Rd +++ b/man/alpha.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colour-manip.r +% Please edit documentation in R/colour-manip.R \name{alpha} \alias{alpha} \title{Modify colour transparency} diff --git a/man/area_pal.Rd b/man/area_pal.Rd index b10eacc2..2dc3184c 100644 --- a/man/area_pal.Rd +++ b/man/area_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-area.r +% Please edit documentation in R/pal-area.R \name{area_pal} \alias{area_pal} \alias{abs_area} diff --git a/man/asn_trans.Rd b/man/asn_trans.Rd index 22149435..8785c6b0 100644 --- a/man/asn_trans.Rd +++ b/man/asn_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{asn_trans} \alias{asn_trans} \title{Arc-sin square root transformation} diff --git a/man/atanh_trans.Rd b/man/atanh_trans.Rd index 2c9e225c..a0b9b78c 100644 --- a/man/atanh_trans.Rd +++ b/man/atanh_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{atanh_trans} \alias{atanh_trans} \title{Arc-tangent transformation} diff --git a/man/boxcox_trans.Rd b/man/boxcox_trans.Rd index eb5c57ee..eed1d071 100644 --- a/man/boxcox_trans.Rd +++ b/man/boxcox_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{boxcox_trans} \alias{boxcox_trans} \alias{modulus_trans} @@ -53,7 +53,7 @@ Journal of the Royal Statistical Society. Series B (Methodological), 211-252. John, J. A., & Draper, N. R. (1980). An alternative family of transformations. Applied Statistics, 190-197. -\url{http://www.jstor.org/stable/2986305} +\url{https://www.jstor.org/stable/2986305} } \seealso{ \code{\link[=yj_trans]{yj_trans()}} diff --git a/man/breaks_extended.Rd b/man/breaks_extended.Rd index d3b10778..6e268749 100644 --- a/man/breaks_extended.Rd +++ b/man/breaks_extended.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/breaks.r +% Please edit documentation in R/breaks.R \name{breaks_extended} \alias{breaks_extended} \alias{extended_breaks} diff --git a/man/breaks_pretty.Rd b/man/breaks_pretty.Rd index 5a43a4c8..0f4a5c6e 100644 --- a/man/breaks_pretty.Rd +++ b/man/breaks_pretty.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/breaks.r +% Please edit documentation in R/breaks.R \name{breaks_pretty} \alias{breaks_pretty} \title{Pretty breaks for date/times} diff --git a/man/breaks_width.Rd b/man/breaks_width.Rd index 0fd96491..362df4b0 100644 --- a/man/breaks_width.Rd +++ b/man/breaks_width.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/breaks.r +% Please edit documentation in R/breaks.R \name{breaks_width} \alias{breaks_width} \title{Equally spaced breaks} diff --git a/man/brewer_pal.Rd b/man/brewer_pal.Rd index dde0d432..dd7e72be 100644 --- a/man/brewer_pal.Rd +++ b/man/brewer_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-brewer.r +% Please edit documentation in R/pal-brewer.R \name{brewer_pal} \alias{brewer_pal} \title{Colour Brewer palette (discrete)} diff --git a/man/col2hcl.Rd b/man/col2hcl.Rd index 2418b90b..bce3f580 100644 --- a/man/col2hcl.Rd +++ b/man/col2hcl.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colour-manip.r +% Please edit documentation in R/colour-manip.R \name{col2hcl} \alias{col2hcl} \title{Modify standard R colour in hcl colour space.} diff --git a/man/col_numeric.Rd b/man/col_numeric.Rd index 5578e150..077c3dce 100644 --- a/man/col_numeric.Rd +++ b/man/col_numeric.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colour-mapping.r +% Please edit documentation in R/colour-mapping.R \name{col_numeric} \alias{col_numeric} \alias{col_bin} diff --git a/man/comma.Rd b/man/comma.Rd index 0ae4fb5b..91b5f915 100644 --- a/man/comma.Rd +++ b/man/comma.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/label-number.r +% Please edit documentation in R/label-number.R \name{comma} \alias{comma} \alias{number_format} diff --git a/man/cscale.Rd b/man/cscale.Rd index 3702c08b..1c65f54d 100644 --- a/man/cscale.Rd +++ b/man/cscale.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-continuous.r +% Please edit documentation in R/scale-continuous.R \name{cscale} \alias{cscale} \title{Continuous scale} diff --git a/man/date_trans.Rd b/man/date_trans.Rd index a52f4dca..6c110199 100644 --- a/man/date_trans.Rd +++ b/man/date_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-date.r +% Please edit documentation in R/trans-date.R \name{date_trans} \alias{date_trans} \title{Transformation for dates (class Date)} diff --git a/man/demo_continuous.Rd b/man/demo_continuous.Rd index d25ea8f5..94576fe3 100644 --- a/man/demo_continuous.Rd +++ b/man/demo_continuous.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.r +% Please edit documentation in R/utils.R \name{demo_continuous} \alias{demo_continuous} \alias{demo_log10} diff --git a/man/dichromat_pal.Rd b/man/dichromat_pal.Rd index e2b1fedc..e79862e7 100644 --- a/man/dichromat_pal.Rd +++ b/man/dichromat_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-dichromat.r +% Please edit documentation in R/pal-dichromat.R \name{dichromat_pal} \alias{dichromat_pal} \title{Dichromat (colour-blind) palette (discrete)} diff --git a/man/div_gradient_pal.Rd b/man/div_gradient_pal.Rd index da3910c1..33aaa41d 100644 --- a/man/div_gradient_pal.Rd +++ b/man/div_gradient_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-gradient.r +% Please edit documentation in R/pal-gradient.R \name{div_gradient_pal} \alias{div_gradient_pal} \title{Diverging colour gradient (continuous).} diff --git a/man/dscale.Rd b/man/dscale.Rd index f9ea380f..212253eb 100644 --- a/man/dscale.Rd +++ b/man/dscale.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-discrete.r +% Please edit documentation in R/scale-discrete.R \name{dscale} \alias{dscale} \title{Discrete scale} diff --git a/man/exp_trans.Rd b/man/exp_trans.Rd index eca9f123..92f5b9e5 100644 --- a/man/exp_trans.Rd +++ b/man/exp_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{exp_trans} \alias{exp_trans} \title{Exponential transformation (inverse of log transformation)} diff --git a/man/expand_range.Rd b/man/expand_range.Rd index ea8ab467..c782cb6b 100644 --- a/man/expand_range.Rd +++ b/man/expand_range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{expand_range} \alias{expand_range} \title{Expand a range with a multiplicative or additive constant} diff --git a/man/figures/README-labels-1.png b/man/figures/README-labels-1.png index 77e702ff..b4c6eb7c 100644 Binary files a/man/figures/README-labels-1.png and b/man/figures/README-labels-1.png differ diff --git a/man/figures/README-transforms-1.png b/man/figures/README-transforms-1.png index 61771342..e5efe4a3 100644 Binary files a/man/figures/README-transforms-1.png and b/man/figures/README-transforms-1.png differ diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg index 48f72a6f..745ab0c7 100644 --- a/man/figures/lifecycle-archived.svg +++ b/man/figures/lifecycle-archived.svg @@ -1 +1,21 @@ - lifecyclelifecyclearchivedarchived \ No newline at end of file + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg index 01452e5f..d5c9559e 100644 --- a/man/figures/lifecycle-defunct.svg +++ b/man/figures/lifecycle-defunct.svg @@ -1 +1,21 @@ -lifecyclelifecycledefunctdefunct \ No newline at end of file + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg index 4baaee01..b61c57c3 100644 --- a/man/figures/lifecycle-deprecated.svg +++ b/man/figures/lifecycle-deprecated.svg @@ -1 +1,21 @@ -lifecyclelifecycledeprecateddeprecated \ No newline at end of file + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg index d1d060e9..5d88fc2c 100644 --- a/man/figures/lifecycle-experimental.svg +++ b/man/figures/lifecycle-experimental.svg @@ -1 +1,21 @@ -lifecyclelifecycleexperimentalexperimental \ No newline at end of file + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg index df713101..897370ec 100644 --- a/man/figures/lifecycle-maturing.svg +++ b/man/figures/lifecycle-maturing.svg @@ -1 +1,21 @@ -lifecyclelifecyclematuringmaturing \ No newline at end of file + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg index 08ee0c90..7c1721d0 100644 --- a/man/figures/lifecycle-questioning.svg +++ b/man/figures/lifecycle-questioning.svg @@ -1 +1,21 @@ -lifecyclelifecyclequestioningquestioning \ No newline at end of file + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 00000000..9c166ff3 --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg index e015dc81..9bf21e76 100644 --- a/man/figures/lifecycle-stable.svg +++ b/man/figures/lifecycle-stable.svg @@ -1 +1,29 @@ -lifecyclelifecyclestablestable \ No newline at end of file + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg index 75f24f55..db8d757f 100644 --- a/man/figures/lifecycle-superseded.svg +++ b/man/figures/lifecycle-superseded.svg @@ -1 +1,21 @@ - lifecyclelifecyclesupersededsuperseded \ No newline at end of file + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/figures/logo.png b/man/figures/logo.png index 3505cae9..b9fbd637 100644 Binary files a/man/figures/logo.png and b/man/figures/logo.png differ diff --git a/man/figures/logo.svg b/man/figures/logo.svg new file mode 100644 index 00000000..712620cb --- /dev/null +++ b/man/figures/logo.svg @@ -0,0 +1,1206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/man/fullseq.Rd b/man/fullseq.Rd index e621d2b8..2e726bf4 100644 --- a/man/fullseq.Rd +++ b/man/fullseq.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/full-seq.r +% Please edit documentation in R/full-seq.R \name{fullseq} \alias{fullseq} \title{Generate sequence of fixed size intervals covering range.} diff --git a/man/gradient_n_pal.Rd b/man/gradient_n_pal.Rd index b560dd3e..7cbbefeb 100644 --- a/man/gradient_n_pal.Rd +++ b/man/gradient_n_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-gradient.r +% Please edit documentation in R/pal-gradient.R \name{gradient_n_pal} \alias{gradient_n_pal} \title{Arbitrary colour gradient palette (continuous)} diff --git a/man/grey_pal.Rd b/man/grey_pal.Rd index f9473115..7bd01256 100644 --- a/man/grey_pal.Rd +++ b/man/grey_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-grey.r +% Please edit documentation in R/pal-grey.R \name{grey_pal} \alias{grey_pal} \title{Grey scale palette (discrete)} diff --git a/man/hms_trans.Rd b/man/hms_trans.Rd index b4384dd2..e01bfa2a 100644 --- a/man/hms_trans.Rd +++ b/man/hms_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-date.r +% Please edit documentation in R/trans-date.R \name{hms_trans} \alias{hms_trans} \title{Transformation for times (class hms)} diff --git a/man/hue_pal.Rd b/man/hue_pal.Rd index 31de63ca..3abcd8bd 100644 --- a/man/hue_pal.Rd +++ b/man/hue_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-hue.r +% Please edit documentation in R/pal-hue.R \name{hue_pal} \alias{hue_pal} \title{Hue palette (discrete)} diff --git a/man/identity_pal.Rd b/man/identity_pal.Rd index 99a97668..028a6246 100644 --- a/man/identity_pal.Rd +++ b/man/identity_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-identity.r +% Please edit documentation in R/pal-identity.R \name{identity_pal} \alias{identity_pal} \title{Identity palette} diff --git a/man/identity_trans.Rd b/man/identity_trans.Rd index 5aa67c2e..efb88769 100644 --- a/man/identity_trans.Rd +++ b/man/identity_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{identity_trans} \alias{identity_trans} \title{Identity transformation (do nothing)} diff --git a/man/label_bytes.Rd b/man/label_bytes.Rd index 2ccca9ff..35120545 100644 --- a/man/label_bytes.Rd +++ b/man/label_bytes.Rd @@ -28,7 +28,44 @@ Applied to rescaled data.} formatting. This is useful if the underlying data is very small or very large.} -\item{...}{Other arguments passed on to \code{\link[=number]{number()}}} +\item{...}{ + Arguments passed on to \code{\link[=number]{number}} + \describe{ + \item{\code{prefix}}{Additional text to display before the number. The suffix is +applied to absolute value before \code{style_positive} and \code{style_negative} are +processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.} + \item{\code{suffix}}{Additional text to display after the number.} + \item{\code{big.mark}}{Character used between every 3 digits to separate thousands.} + \item{\code{decimal.mark}}{The character to be used to indicate the numeric +decimal point.} + \item{\code{style_positive}}{A string that determines the style of positive numbers: +\itemize{ +\item \code{"none"} (the default): no change, e.g. \code{1}. +\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}. +}} + \item{\code{style_negative}}{A string that determines the style of negative numbers: +\itemize{ +\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}. +\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical +nicety that ensures \code{-} aligns with the horizontal bar of the +the horizontal bar of \code{+}. +\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}. +}} + \item{\code{scale_cut}}{Named numeric vector that allows you to rescale large +(or small) numbers and add a prefix. Built-in helpers include: +\itemize{ +\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T. +\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T. +\item \code{cut_si(unit)}: uses standard SI units. +} + +If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the +range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)} +will be divided by 100 and given the suffix "a", and absolute values in +the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".} + \item{\code{trim}}{Logical, if \code{FALSE}, values are right-justified to a common +width (see \code{\link[base:format]{base::format()}}).} + }} } \value{ A labeller function that takes a numeric vector of breaks and diff --git a/man/label_dollar.Rd b/man/label_dollar.Rd index 792299a2..ef5cee8b 100644 --- a/man/label_dollar.Rd +++ b/man/label_dollar.Rd @@ -40,7 +40,35 @@ width (see \code{\link[base:format]{base::format()}}).} \item{negative_parens}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Use \code{style_negative = "parens"} instead.} -\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.} +\item{...}{ + Arguments passed on to \code{\link[=number]{number}} + \describe{ + \item{\code{style_positive}}{A string that determines the style of positive numbers: +\itemize{ +\item \code{"none"} (the default): no change, e.g. \code{1}. +\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}. +}} + \item{\code{style_negative}}{A string that determines the style of negative numbers: +\itemize{ +\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}. +\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical +nicety that ensures \code{-} aligns with the horizontal bar of the +the horizontal bar of \code{+}. +\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}. +}} + \item{\code{scale_cut}}{Named numeric vector that allows you to rescale large +(or small) numbers and add a prefix. Built-in helpers include: +\itemize{ +\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T. +\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T. +\item \code{cut_si(unit)}: uses standard SI units. +} + +If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the +range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)} +will be divided by 100 and given the suffix "a", and absolute values in +the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".} + }} } \value{ All \code{label_()} functions return a "labelling" function, i.e. a function that diff --git a/man/label_number.Rd b/man/label_number.Rd index ac73acc1..5cdd0b18 100644 --- a/man/label_number.Rd +++ b/man/label_number.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/label-number.r +% Please edit documentation in R/label-number.R \name{label_number} \alias{label_number} \alias{label_comma} diff --git a/man/label_number_si.Rd b/man/label_number_si.Rd index 00e43db6..df2d0d57 100644 --- a/man/label_number_si.Rd +++ b/man/label_number_si.Rd @@ -22,7 +22,43 @@ prefix.} \item{suffix}{Additional text to display after the number.} -\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.} +\item{...}{ + Arguments passed on to \code{\link[=label_number]{label_number}} + \describe{ + \item{\code{prefix}}{Additional text to display before the number. The suffix is +applied to absolute value before \code{style_positive} and \code{style_negative} are +processed so that \code{prefix = "$"} will yield (e.g.) \verb{-$1} and \verb{($1)}.} + \item{\code{big.mark}}{Character used between every 3 digits to separate thousands.} + \item{\code{decimal.mark}}{The character to be used to indicate the numeric +decimal point.} + \item{\code{style_positive}}{A string that determines the style of positive numbers: +\itemize{ +\item \code{"none"} (the default): no change, e.g. \code{1}. +\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}. +}} + \item{\code{style_negative}}{A string that determines the style of negative numbers: +\itemize{ +\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}. +\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical +nicety that ensures \code{-} aligns with the horizontal bar of the +the horizontal bar of \code{+}. +\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}. +}} + \item{\code{scale_cut}}{Named numeric vector that allows you to rescale large +(or small) numbers and add a prefix. Built-in helpers include: +\itemize{ +\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T. +\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T. +\item \code{cut_si(unit)}: uses standard SI units. +} + +If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the +range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)} +will be divided by 100 and given the suffix "a", and absolute values in +the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".} + \item{\code{trim}}{Logical, if \code{FALSE}, values are right-justified to a common +width (see \code{\link[base:format]{base::format()}}).} + }} } \value{ All \code{label_()} functions return a "labelling" function, i.e. a function that diff --git a/man/label_ordinal.Rd b/man/label_ordinal.Rd index eb82bf23..68be92f5 100644 --- a/man/label_ordinal.Rd +++ b/man/label_ordinal.Rd @@ -29,7 +29,48 @@ ordinal_spanish() \item{rules}{Named list of regular expressions, matched in order. Name gives suffix, and value specifies which numbers to match.} -\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.} +\item{...}{ + Arguments passed on to \code{\link[=number]{number}} + \describe{ + \item{\code{accuracy}}{A number to round to. Use (e.g.) \code{0.01} to show 2 decimal +places of precision. If \code{NULL}, the default, uses a heuristic that should +ensure breaks have the minimum number of digits needed to show the +difference between adjacent values. + +Applied to rescaled data.} + \item{\code{scale}}{A scaling factor: \code{x} will be multiplied by \code{scale} before +formatting. This is useful if the underlying data is very small or very +large.} + \item{\code{decimal.mark}}{The character to be used to indicate the numeric +decimal point.} + \item{\code{style_positive}}{A string that determines the style of positive numbers: +\itemize{ +\item \code{"none"} (the default): no change, e.g. \code{1}. +\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}. +}} + \item{\code{style_negative}}{A string that determines the style of negative numbers: +\itemize{ +\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}. +\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical +nicety that ensures \code{-} aligns with the horizontal bar of the +the horizontal bar of \code{+}. +\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}. +}} + \item{\code{scale_cut}}{Named numeric vector that allows you to rescale large +(or small) numbers and add a prefix. Built-in helpers include: +\itemize{ +\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T. +\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T. +\item \code{cut_si(unit)}: uses standard SI units. +} + +If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the +range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)} +will be divided by 100 and given the suffix "a", and absolute values in +the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".} + \item{\code{trim}}{Logical, if \code{FALSE}, values are right-justified to a common +width (see \code{\link[base:format]{base::format()}}).} + }} \item{gender}{Masculin or feminin gender for French ordinal.} diff --git a/man/label_percent.Rd b/man/label_percent.Rd index a43662c9..ffb018ea 100644 --- a/man/label_percent.Rd +++ b/man/label_percent.Rd @@ -41,7 +41,35 @@ decimal point.} \item{trim}{Logical, if \code{FALSE}, values are right-justified to a common width (see \code{\link[base:format]{base::format()}}).} -\item{...}{Other arguments passed on to \code{\link[base:format]{base::format()}}.} +\item{...}{ + Arguments passed on to \code{\link[=label_number]{label_number}} + \describe{ + \item{\code{style_positive}}{A string that determines the style of positive numbers: +\itemize{ +\item \code{"none"} (the default): no change, e.g. \code{1}. +\item \code{"plus"}: preceded by \code{+}, e.g. \code{+1}. +}} + \item{\code{style_negative}}{A string that determines the style of negative numbers: +\itemize{ +\item \code{"hyphen"} (the default): preceded by a standard hypen \code{-}, e.g. \code{-1}. +\item \code{"minus"}, uses a proper Unicode minus symbol. This is a typographical +nicety that ensures \code{-} aligns with the horizontal bar of the +the horizontal bar of \code{+}. +\item \code{"parens"}, wrapped in parentheses, e.g. \code{(1)}. +}} + \item{\code{scale_cut}}{Named numeric vector that allows you to rescale large +(or small) numbers and add a prefix. Built-in helpers include: +\itemize{ +\item \code{cut_short_scale()}: [10^3, 10^6) = K, [10^6, 10^9) = M, [10^9, 10^12) = B, [10^12, Inf) = T. +\item \code{cut_long_scale()}: [10^3, 10^6) = K, [10^6, 10^12) = M, [10^12, 10^18) = B, [10^18, Inf) = T. +\item \code{cut_si(unit)}: uses standard SI units. +} + +If you supply a vector \code{c(a = 100, b = 1000)}, absolute values in the +range \verb{[0, 100)} will not be rescaled, absolute values in the range \verb{[100, 1000)} +will be divided by 100 and given the suffix "a", and absolute values in +the range \verb{[1000, Inf)} will be divided by 1000 and given the suffix "b".} + }} } \value{ All \code{label_()} functions return a "labelling" function, i.e. a function that diff --git a/man/linetype_pal.Rd b/man/linetype_pal.Rd index bf08538d..d4404b8f 100644 --- a/man/linetype_pal.Rd +++ b/man/linetype_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-linetype.r +% Please edit documentation in R/pal-linetype.R \name{linetype_pal} \alias{linetype_pal} \title{Line type palette (discrete)} diff --git a/man/log_trans.Rd b/man/log_trans.Rd index 3f9287fd..2e6619c6 100644 --- a/man/log_trans.Rd +++ b/man/log_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{log_trans} \alias{log_trans} \alias{log10_trans} diff --git a/man/manual_pal.Rd b/man/manual_pal.Rd index 73f937d0..b7ff407d 100644 --- a/man/manual_pal.Rd +++ b/man/manual_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-manual.r +% Please edit documentation in R/pal-manual.R \name{manual_pal} \alias{manual_pal} \title{Manual palette (discrete)} diff --git a/man/muted.Rd b/man/muted.Rd index 4f62de8f..f38e09c7 100644 --- a/man/muted.Rd +++ b/man/muted.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colour-manip.r +% Please edit documentation in R/colour-manip.R \name{muted} \alias{muted} \title{Mute standard colour} diff --git a/man/number.Rd b/man/number.Rd index a8fd5af8..e5f6554a 100644 --- a/man/number.Rd +++ b/man/number.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/label-number.r +% Please edit documentation in R/label-number.R \name{number} \alias{number} \alias{cut_short_scale} diff --git a/man/oob.Rd b/man/oob.Rd index 4e820a3d..db190b36 100644 --- a/man/oob.Rd +++ b/man/oob.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{oob} \alias{oob} \alias{oob_censor} diff --git a/man/pretty_breaks.Rd b/man/pretty_breaks.Rd index f617a2d0..8543c354 100644 --- a/man/pretty_breaks.Rd +++ b/man/pretty_breaks.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/breaks.r +% Please edit documentation in R/breaks.R \name{pretty_breaks} \alias{pretty_breaks} \title{Superseded interface to \code{breaks_pretty()}} diff --git a/man/probability_trans.Rd b/man/probability_trans.Rd index 5c9d29a0..67ca1771 100644 --- a/man/probability_trans.Rd +++ b/man/probability_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{probability_trans} \alias{probability_trans} \alias{logit_trans} diff --git a/man/reciprocal_trans.Rd b/man/reciprocal_trans.Rd index 2bcf32e7..aec21d60 100644 --- a/man/reciprocal_trans.Rd +++ b/man/reciprocal_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{reciprocal_trans} \alias{reciprocal_trans} \title{Reciprocal transformation} diff --git a/man/rescale.Rd b/man/rescale.Rd index 3ff52d54..1383eeea 100644 --- a/man/rescale.Rd +++ b/man/rescale.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{rescale} \alias{rescale} \alias{rescale.numeric} diff --git a/man/rescale_max.Rd b/man/rescale_max.Rd index 0677fc81..d9d0d080 100644 --- a/man/rescale_max.Rd +++ b/man/rescale_max.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{rescale_max} \alias{rescale_max} \title{Rescale numeric vector to have specified maximum} diff --git a/man/rescale_mid.Rd b/man/rescale_mid.Rd index 3000e57e..c9bf7392 100644 --- a/man/rescale_mid.Rd +++ b/man/rescale_mid.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{rescale_mid} \alias{rescale_mid} \alias{rescale_mid.numeric} diff --git a/man/rescale_none.Rd b/man/rescale_none.Rd index 746c615a..03fa60f1 100644 --- a/man/rescale_none.Rd +++ b/man/rescale_none.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{rescale_none} \alias{rescale_none} \title{Don't perform rescaling} diff --git a/man/rescale_pal.Rd b/man/rescale_pal.Rd index aeac61d3..7fa3a584 100644 --- a/man/rescale_pal.Rd +++ b/man/rescale_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-rescale.r +% Please edit documentation in R/pal-rescale.R \name{rescale_pal} \alias{rescale_pal} \title{Rescale palette (continuous)} diff --git a/man/reverse_trans.Rd b/man/reverse_trans.Rd index 77f38227..049f5499 100644 --- a/man/reverse_trans.Rd +++ b/man/reverse_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{reverse_trans} \alias{reverse_trans} \title{Reverse transformation} @@ -7,7 +7,9 @@ reverse_trans() } \description{ -Reverse transformation +reversing transformation works by multiplying the input with -1. This means +that reverse transformation cannot easily be composed with transformations +that require positive input unless the reversing is done as a final step. } \examples{ plot(reverse_trans(), xlim = c(-1, 1)) diff --git a/man/scales-package.Rd b/man/scales-package.Rd index 49cedbcd..eb4f1632 100644 --- a/man/scales-package.Rd +++ b/man/scales-package.Rd @@ -20,16 +20,17 @@ Useful links: } \author{ -\strong{Maintainer}: Hadley Wickham \email{hadley@rstudio.com} +\strong{Maintainer}: Thomas Lin Pedersen \email{thomasp85@posit.co} (\href{https://orcid.org/0000-0002-5147-4711}{ORCID}) Authors: \itemize{ + \item Hadley Wickham \email{hadley@posit.co} \item Dana Seidel } Other contributors: \itemize{ - \item RStudio [copyright holder, funder] + \item Posit, PBC [copyright holder, funder] } } diff --git a/man/seq_gradient_pal.Rd b/man/seq_gradient_pal.Rd index 15976d74..32973b3f 100644 --- a/man/seq_gradient_pal.Rd +++ b/man/seq_gradient_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-gradient.r +% Please edit documentation in R/pal-gradient.R \name{seq_gradient_pal} \alias{seq_gradient_pal} \title{Sequential colour gradient palette (continuous)} diff --git a/man/shape_pal.Rd b/man/shape_pal.Rd index cf74d4ce..a3c69ccc 100644 --- a/man/shape_pal.Rd +++ b/man/shape_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-shape.r +% Please edit documentation in R/pal-shape.R \name{shape_pal} \alias{shape_pal} \title{Shape palette (discrete)} diff --git a/man/show_col.Rd b/man/show_col.Rd index 5a2bdaf7..e51c00f1 100644 --- a/man/show_col.Rd +++ b/man/show_col.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colour-manip.r +% Please edit documentation in R/colour-manip.R \name{show_col} \alias{show_col} \title{Show colours} diff --git a/man/sqrt_trans.Rd b/man/sqrt_trans.Rd index 6137f8b9..f2695747 100644 --- a/man/sqrt_trans.Rd +++ b/man/sqrt_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{sqrt_trans} \alias{sqrt_trans} \title{Square-root transformation} diff --git a/man/time_trans.Rd b/man/time_trans.Rd index 37224014..8b473327 100644 --- a/man/time_trans.Rd +++ b/man/time_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-date.r +% Please edit documentation in R/trans-date.R \name{time_trans} \alias{time_trans} \title{Transformation for date-times (class POSIXt)} diff --git a/man/train_continuous.Rd b/man/train_continuous.Rd index 0703501f..ece41995 100644 --- a/man/train_continuous.Rd +++ b/man/train_continuous.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-continuous.r +% Please edit documentation in R/scale-continuous.R \name{train_continuous} \alias{train_continuous} \title{Train (update) a continuous scale} diff --git a/man/train_discrete.Rd b/man/train_discrete.Rd index fd8ea115..073e1a2b 100644 --- a/man/train_discrete.Rd +++ b/man/train_discrete.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/scale-discrete.r +% Please edit documentation in R/scale-discrete.R \name{train_discrete} \alias{train_discrete} \title{Train (update) a discrete scale} diff --git a/man/trans_new.Rd b/man/trans_new.Rd index 00d59b0c..33c01e76 100644 --- a/man/trans_new.Rd +++ b/man/trans_new.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans.r +% Please edit documentation in R/trans.R \name{trans_new} \alias{trans_new} \alias{trans} diff --git a/man/trans_range.Rd b/man/trans_range.Rd index 8a05b00a..14363080 100644 --- a/man/trans_range.Rd +++ b/man/trans_range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans.r +% Please edit documentation in R/trans.R \name{trans_range} \alias{trans_range} \title{Compute range of transformed values} diff --git a/man/viridis_pal.Rd b/man/viridis_pal.Rd index 0a33ff05..0fa20328 100644 --- a/man/viridis_pal.Rd +++ b/man/viridis_pal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pal-viridis.r +% Please edit documentation in R/pal-viridis.R \name{viridis_pal} \alias{viridis_pal} \title{Viridis palette} @@ -20,14 +20,14 @@ reversed.} \item{option}{A character string indicating the color map option to use. Eight options are available: \itemize{ - \item "magma" (or "A") - \item "inferno" (or "B") - \item "plasma" (or "C") - \item "viridis" (or "D") - \item "cividis" (or "E") - \item "rocket" (or "F") - \item "mako" (or "G") - \item "turbo" (or "H") + \item{}{"magma" (or "A")} + \item{}{"inferno" (or "B")} + \item{}{"plasma" (or "C")} + \item{}{"viridis" (or "D")} + \item{}{"cividis" (or "E")} + \item{}{"rocket" (or "F")} + \item{}{"mako" (or "G")} + \item{}{"turbo" (or "H")} }} } \description{ diff --git a/man/yj_trans.Rd b/man/yj_trans.Rd index c99246da..f129e416 100644 --- a/man/yj_trans.Rd +++ b/man/yj_trans.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/trans-numeric.r +% Please edit documentation in R/trans-numeric.R \name{yj_trans} \alias{yj_trans} \title{Yeo-Johnson transformation} @@ -36,5 +36,5 @@ plot(yj_trans(2), xlim = c(-10, 10)) \references{ Yeo, I., & Johnson, R. (2000). A New Family of Power Transformations to Improve Normality or Symmetry. Biometrika, 87(4), 954-959. -\url{http://www.jstor.org/stable/2673623} +\url{https://www.jstor.org/stable/2673623} } diff --git a/man/zero_range.Rd b/man/zero_range.Rd index f0576301..f926cbe7 100644 --- a/man/zero_range.Rd +++ b/man/zero_range.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bounds.r +% Please edit documentation in R/bounds.R \name{zero_range} \alias{zero_range} \title{Determine if range of vector is close to zero, with a specified tolerance} diff --git a/tests/testthat/_snaps/trans-compose.md b/tests/testthat/_snaps/trans-compose.md index 4d362c7b..1023d08b 100644 --- a/tests/testthat/_snaps/trans-compose.md +++ b/tests/testthat/_snaps/trans-compose.md @@ -4,7 +4,7 @@ compose_trans() Condition Error in `compose_trans()`: - ! Must include at least 1 transformer to compose + ! `compose_trans()` must include at least 1 transformer to compose Code compose_trans("reverse", "log10") Condition diff --git a/tests/testthat/_snaps/trans-date.md b/tests/testthat/_snaps/trans-date.md new file mode 100644 index 00000000..ff41bec3 --- /dev/null +++ b/tests/testthat/_snaps/trans-date.md @@ -0,0 +1,8 @@ +# date/time scales raise error on incorrect inputs + + `time_trans()` works with objects of class only + +--- + + `date_trans()` works with objects of class only + diff --git a/tests/testthat/test-bounds.r b/tests/testthat/test-bounds.R similarity index 100% rename from tests/testthat/test-bounds.r rename to tests/testthat/test-bounds.R diff --git a/tests/testthat/test-breaks-log.r b/tests/testthat/test-breaks-log.R similarity index 100% rename from tests/testthat/test-breaks-log.r rename to tests/testthat/test-breaks-log.R diff --git a/tests/testthat/test-breaks.r b/tests/testthat/test-breaks.R similarity index 100% rename from tests/testthat/test-breaks.r rename to tests/testthat/test-breaks.R diff --git a/tests/testthat/test-colour-manip.r b/tests/testthat/test-colour-manip.R similarity index 100% rename from tests/testthat/test-colour-manip.r rename to tests/testthat/test-colour-manip.R diff --git a/tests/testthat/test-colour-mapping.r b/tests/testthat/test-colour-mapping.R similarity index 100% rename from tests/testthat/test-colour-mapping.r rename to tests/testthat/test-colour-mapping.R diff --git a/tests/testthat/test-full-seq.r b/tests/testthat/test-full-seq.R similarity index 100% rename from tests/testthat/test-full-seq.r rename to tests/testthat/test-full-seq.R diff --git a/tests/testthat/test-label-number.r b/tests/testthat/test-label-number.R similarity index 100% rename from tests/testthat/test-label-number.r rename to tests/testthat/test-label-number.R diff --git a/tests/testthat/test-pal-hue.r b/tests/testthat/test-pal-hue.R similarity index 100% rename from tests/testthat/test-pal-hue.r rename to tests/testthat/test-pal-hue.R diff --git a/tests/testthat/test-range.r b/tests/testthat/test-range.R similarity index 100% rename from tests/testthat/test-range.r rename to tests/testthat/test-range.R diff --git a/tests/testthat/test-scale-continuous.r b/tests/testthat/test-scale-continuous.R similarity index 100% rename from tests/testthat/test-scale-continuous.r rename to tests/testthat/test-scale-continuous.R diff --git a/tests/testthat/test-scale-discrete.r b/tests/testthat/test-scale-discrete.R similarity index 100% rename from tests/testthat/test-scale-discrete.r rename to tests/testthat/test-scale-discrete.R diff --git a/tests/testthat/test-trans-date.r b/tests/testthat/test-trans-date.R similarity index 93% rename from tests/testthat/test-trans-date.r rename to tests/testthat/test-trans-date.R index 52957836..38092367 100644 --- a/tests/testthat/test-trans-date.r +++ b/tests/testthat/test-trans-date.R @@ -10,10 +10,10 @@ with_tz <- function(x, value) { test_that("date/time scales raise error on incorrect inputs", { time <- time_trans() - expect_error(time$transform(a_date), "Invalid input") + expect_snapshot_error(time$transform(a_date)) date <- date_trans() - expect_error(date$transform(a_time), "Invalid input") + expect_snapshot_error(date$transform(a_time)) }) test_that("time scales learn timezones", { diff --git a/tests/testthat/test-trans-numeric.r b/tests/testthat/test-trans-numeric.R similarity index 100% rename from tests/testthat/test-trans-numeric.r rename to tests/testthat/test-trans-numeric.R diff --git a/tests/testthat/test-trans.r b/tests/testthat/test-trans.R similarity index 100% rename from tests/testthat/test-trans.r rename to tests/testthat/test-trans.R