rescale_capped: wraps scales::rescale to enforce range of 'to' on output

View source: R/functions_util.R

rescale_cappedR Documentation

wraps scales::rescale to enforce range of to on output

Description

wraps scales::rescale to enforce range of to on output

Usage

rescale_capped(x, to = c(0, 1), from = range(x, na.rm = TRUE, finite = TRUE))

Arguments

x

continuous vector of values to manipulate.

to

output range (numeric vector of length two)

from

input range (vector of length two). If not given, is calculated from the range of x

Value

x rescaled from from domain to to domain, within bounds of to

Examples

#behaves identically to scales::rescale when x is within 'from' domain
chiptsne:::rescale_capped(0:10, to = c(0, 1), c(0, 10))
scales::rescale(0:10, to = c(0, 1), c(0, 10))
#when x exceeds 'from' domain, results are still within 'to' domain
chiptsne:::rescale_capped(0:10, to = c(0,1), c(0,5))
#not true for scales::rescale
scales::rescale(0:10, to = c(0,1), c(0,5))

jrboyd/seqtsne documentation built on Nov. 5, 2022, 6:37 a.m.