This function follows the squish_infinite function, but allows extentions that work with other objects than numeric vectors.

squish_infiniteThis(x, range = NULL, aes = "z")

# S4 method for numeric,numeric_OR_missing
squish_infiniteThis(x, range = c(0, 1), aes = "z")

# S4 method for Rle,numeric_OR_missing
squish_infiniteThis(x, range = c(0, 1), aes = "z")

# S4 method for WoodenHorse,numeric_OR_missing
squish_infiniteThis(x, range = c(0, 1), aes = "z")

Arguments

x

A vector of values to manipulate.

range

A range representing object.

aes

An aesthetic for which to evaluate the function.

Value

The x argument, but with infinite values squished to the range.

Examples

# For regular numeric vectors squish_infiniteThis(c(-Inf, -1, 0, 1, 2, Inf))
#> [1] 0 -1 0 1 2 1
# For Rle-class squish_infiniteThis(Rle(c(Inf, 2, 3, -Inf), 1:4), c(2, 3))
#> numeric-Rle of length 10 with 4 runs #> Lengths: 1 2 3 4 #> Values : 3 2 3 2