Skip to content

Commit

Permalink
cleaner if subscale only accept numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Apr 2, 2024
1 parent 19e9896 commit 7739835
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
8 changes: 3 additions & 5 deletions R/subscale.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' used with the `subscale` parameter of [geom_slabinterval()].
#' @template description-auto-partial
#'
#' @param x a [numeric] or [thickness] vector to be rescaled.
#' @param x a [numeric] vector to be rescaled.
#' Typically provided automatically by [geom_slabinterval()].
#' @param expand A numeric vector of limit expansion constants of length
#' 2 or 4, following the same format used by the `expand` argument of
Expand Down Expand Up @@ -69,10 +69,8 @@ subscale_thickness = auto_partial(name = "subscale_thickness", function(
#' @family sub-scales
#' @export
subscale_identity = function(x) {
x = as_thickness(x)
limits = range(0, 1, field(x, "x"), na.rm = TRUE, finite = TRUE)
field(x, "x") = oob_squish_infinite(field(x, "x"), range = limits)
x
limits = range(0, 1, x, na.rm = TRUE, finite = TRUE)
thickness(oob_squish_infinite(x, range = limits))
}


Expand Down
2 changes: 1 addition & 1 deletion man/subscale_identity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/subscale_thickness.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions man/thickness.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7739835

Please sign in to comment.