Rescale Data to Lie Between Specified Limits

Share:

Description

Rescales a dataset so that the values range exactly between the specified limits.

Usage

1
2
3
4
5
  scaletointerval(x, from=0, to=1, xrange=range(x))
  ## Default S3 method:
scaletointerval(x, from=0, to=1, xrange=range(x))
  ## S3 method for class 'im'
scaletointerval(x, from=0, to=1, xrange=range(x))

Arguments

x

Data to be rescaled.

from,to

Lower and upper endpoints of the interval to which the values of x should be rescaled.

xrange

Optional range of values of x that should be mapped to the new interval.

Details

These functions rescale a dataset x so that its values range exactly between the limits from and to.

The method for pixel images (objects of class "im") applies this scaling to the pixel values of x.

Rescaling cannot be performed if the values in x are not interpretable as numeric, or if the values in x are all equal.

Value

An object of the same type as x.

Author(s)

\adrian

and \rolf

See Also

scale

Examples

1
2
3
4
  X <- as.im(function(x,y) {x+y+3}, unit.square())
  summary(X)
  Y <- scaletointerval(X)
  summary(Y)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.