rescaleVector: Rescales a vector within given bounds.

View source: R/rescaleVector.R

rescaleVectorR Documentation

Rescales a vector within given bounds.

Description

Takes a numeric vector x and rescales it within the values given by new.min and new.max.

Usage

rescaleVector(
  x = rnorm(100),
  new.min = 0,
  new.max = 100,
  integer = FALSE
  )

Arguments

x

numeric vector to be rescaled.

new.min

numeric, new minimum value for x. Default is 0.

new.max

numeric, new maximum value for x. Default is 100.

integer

boolean, if TRUE, output vector is returned as vector of integers. Default is FALSE.

Value

A vector of the same length as x rescaled between output.min and output.max.

Author(s)

Blas M. Benito <blasbenito@gmail.com>

Examples

#generating example data
x = rnorm(100)

#as float
x.float <- rescaleVector(
  x = x,
  new.min = 0,
  new.max = 100,
  integer = FALSE
  )

#as integer
x.integer <- rescaleVector(
  x = x,
  new.min = 0,
  new.max = 100,
  integer = TRUE
  )


virtualPollen documentation built on March 18, 2022, 6:16 p.m.