linearMap: Linear mapping of a numeric vector or scalar

Description Usage Arguments Details Value Author(s) Examples

View source: R/linearMap.R

Description

Linear mapping of a numeric vector or scalar from one closed interval to another

Usage

1
linearMap(x, D = range(x), R = c(0, 1))

Arguments

x

a numeric vector

D

a vector with 2 elements, the first being the lower endpoint of the domain, the upper being the upper endpoint of the domain. Note R[1] must be less than R[2].

R

a vector with 2 elements indicating the range of the linear mapping. R[1] is mapped to D[1], and R[2] is mapped to D[2].

Details

The mapping is f : D --> R, where f(D[1]) = R[1] and f(D[2]) = R[2].

Value

The linear mapping of x from D to R

Author(s)

Landon Sego

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x <- seq(0, 1, length = 5)

# An increasing linear map
linearMap(x, R = c(4, 7))

# A decreasing map
linearMap(x, R = c(7, 4))

# A shift
linearMap(x, R = c(-1, 0))

# The identity map:
y <- linearMap(x, D = c(0, 1), R = c(0, 1))
identical(y, x)

Smisc documentation built on May 2, 2019, 2:46 a.m.