setrange: Sets the range of the input object 'x' to [a,b] (stretching...

View source: R/setrange.R

setrangeR Documentation

Sets the range of the input object 'x' to [a,b] (stretching or shrinking and displacing 'x'). The calculation is done by the following procedure: (x - min(x)) * (b-a) / (max(x) - min(x)) + a = x * s - min(x) * s + a , s=(b-a)/(max(x)-min(x)) = x*s+q , q=a-min(x)*s

Description

Sets the range of the input object 'x' to [a,b] (stretching or shrinking and displacing 'x'). The calculation is done by the following procedure: (x - min(x)) * (b-a) / (max(x) - min(x)) + a = x * s - min(x) * s + a , s=(b-a)/(max(x)-min(x)) = x*s+q , q=a-min(x)*s

Usage

setrange(x, a = 0, b = 1, clamp = NULL, check.ends = TRUE)

Arguments

x

The input object. If all elements are equal, all elements are replaced by 'a'.

a

The lower value of the new range, or the range if length(a)>1. Defaulted to 0.

b

The upper value of the new range. Defaulted to 1.

clamp

Either (1) a vector of two element setting the boundaries outside which the data are clamped to the boundary values, (2) a vector of three elements, indicating that the first two elements are in fraction of the data range, or (3) NULL to keep the original data. As an example, if x=c(-12,-4,-3,0,2,7), and clamp=c(-3,3), the 'x' is transformed to x=c(-3,-3,-3,0,2,3) before setting the range.

check.ends

Logical: If TRUE (default) chech that the end points are inside requested range.


arnejohannesholmin/TSD documentation built on April 14, 2024, 5:29 a.m.