From 773983596d81233ac59f1404d79e5e966437a8e5 Mon Sep 17 00:00:00 2001 From: Matthew Kay Date: Tue, 2 Apr 2024 13:41:53 -0500 Subject: [PATCH] cleaner if subscale only accept numerics --- R/subscale.R | 8 +++----- man/subscale_identity.Rd | 2 +- man/subscale_thickness.Rd | 2 +- man/thickness.Rd | 7 ++----- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/R/subscale.R b/R/subscale.R index 3891e0d4..f9c3a224 100755 --- a/R/subscale.R +++ b/R/subscale.R @@ -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 @@ -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)) } diff --git a/man/subscale_identity.Rd b/man/subscale_identity.Rd index 801346cd..dd05e184 100755 --- a/man/subscale_identity.Rd +++ b/man/subscale_identity.Rd @@ -7,7 +7,7 @@ subscale_identity(x) } \arguments{ -\item{x}{a \link{numeric} or \link{thickness} vector to be rescaled. +\item{x}{a \link{numeric} vector to be rescaled. Typically provided automatically by \code{\link[=geom_slabinterval]{geom_slabinterval()}}.} } \value{ diff --git a/man/subscale_thickness.Rd b/man/subscale_thickness.Rd index 5438e190..acca3934 100755 --- a/man/subscale_thickness.Rd +++ b/man/subscale_thickness.Rd @@ -11,7 +11,7 @@ subscale_thickness( ) } \arguments{ -\item{x}{a \link{numeric} or \link{thickness} vector to be rescaled. +\item{x}{a \link{numeric} vector to be rescaled. Typically provided automatically by \code{\link[=geom_slabinterval]{geom_slabinterval()}}.} \item{expand}{A numeric vector of limit expansion constants of length diff --git a/man/thickness.Rd b/man/thickness.Rd index 7b1d8a89..6946be77 100755 --- a/man/thickness.Rd +++ b/man/thickness.Rd @@ -42,11 +42,8 @@ However, \link{thickness} objects with \code{NA} limits may be combined with locations on the \link{thickness} scale that are independent of data limits. } \examples{ -thk = thickness(0:1) -thk - -thk = thickness(0:1, 0, 10) -thk +thickness(0:1) +thickness(0:1, 0, 10) } \seealso{ The \code{thickness} aesthetic of \code{\link[=geom_slabinterval]{geom_slabinterval()}}.