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

View source: R/graphtest-functions.R

scale_safelyR Documentation

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

Description

Copied from https://github.com/briatte/ggnetwork/blob/f3b8b84d28a65620a94f7aecd769c0ea939466e3/R/utilities.R so as to fix a problem with the cran version of ggnetwork.

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


jfukuyama/phyloseqGraphTest documentation built on Feb. 11, 2024, 4:09 a.m.