Learn R Programming

RPMG (version 2.2-7)

RESCALE: Rescale a vector to fit in a certain range

Description

Rescale a vector to fit in a certain range

Usage

RESCALE(x, nx1=0, nx2=1, minx=0, maxx=1)

Value

Scale version of x vector is returned.

Arguments

x

vector

nx1

new minimum

nx2

new maximum

minx

old min

maxx

old max

Author

Jonathan M. Lees<jonathan.lees.edu>

Details

Rescaling a vector, mostly used for graphics. If x does not vary, i.e. it is constant or minx and max are identical, the mean value of nx1 and nx2 is returned.

Examples

Run this code
x = rnorm(10)
RESCALE(x, 3, 9, min(x), max(x) )

Run the code above in your browser using DataLab