scale_safely: Rescale x to (0, 1), except if x is constant

View source: R/utilities.R

scale_safelyR Documentation

Rescale x to (0, 1), except if x is constant

Description

Discussed in PR #32: https://github.com/briatte/ggnetwork/pull/32

Usage

scale_safely(x, scale = diff(range(x)))

Arguments

x

a vector to rescale

scale

the scale on which to rescale the vector

Value

The rescaled vector, coerced to a vector if necessary. If the original vector was constant, all of its values are replaced by 0.5.

Author(s)

Kipp Johnson


briatte/ggnetwork documentation built on Feb. 16, 2024, 5:45 a.m.