# elascer: Elastic Scaler - A Flexible Rescale Function In ManyLabsOpenScience/manylabRs: Analysis scripts and data from the Many Labs projects

## Description

The 'elastic scaler'will rescale numeric vectors (1D, or columns in a matrix or data.frame) to a user defined minimum and maximum, either based on the extrema in the data, or, a minimum and maximum defined by the user.

The 'elastic scaler'will rescale numeric vectors (1D, or columns in a matrix or data.frame) to a user defined minimum and maximum, either based on the extrema in the data, or, a minimum and maximum defined by the user.

## Usage

 ```1 2 3 4 5``` ```elascer(x, mn = min(x, na.rm = T), mx = max(x, na.rm = T), lo = 0, hi = 1) elascer(x, mn = min(x, na.rm = T), mx = max(x, na.rm = T), lo = 0, hi = 1) ```

## Arguments

 `x` Input vector or data frame. `mn` Minimum value of original, defaults to `min(x, na.rm = TRUE)`. `mx` Maximum value of original, defaults to `max(x, na.rm = TRUE)`. `lo` Maximum value to rescale to, defaults to `1`. `hi` Minimum value to rescale to, defaults to `0`. `x` Input vector or data frame. `mn` Minimum value of original, defaults to `min(x, na.rm = TRUE)`. `mx` Maximum value of original, defaults to `max(x, na.rm = TRUE)`. `hi` Minimum value to rescale to, defaults to `0`. `lo` Maximum value to rescale to, defaults to `1`.

## Details

Three uses:

1. elascer(x) - Scale x to data range: min(x.out)==0; max(x.out)==1

2. elascer(x,mn,mx) - Scale x to arg. range: min(x.out)==mn==0; max(x.out)==mx==1

3. elascer(x,mn,mx,lo,hi) - Scale x to arg. range: min(x.out)==mn==lo; max(x.out)==mx==hi

Three uses:

1. elascer(x) - Scale x to data range: min(x.out)==0; max(x.out)==1

2. elascer(x,mn,mx) - Scale x to arg. range: min(x.out)==mn==0; max(x.out)==mx==1

3. elascer(x,mn,mx,lo,hi) - Scale x to arg. range: min(x.out)==mn==lo; max(x.out)==mx==hi

scaled inout

scaled inout

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```# Works on numeric objects somenumbers <- cbind(c(-5,100,sqrt(2)),c(exp(1),0,-pi)) elascer(somenumbers) elascer(somenumbers,mn=-100) # Values < mn will return < lo (default=0) # Values > mx will return > hi (default=1) elascer(somenumbers,mn=-1,mx=99) elascer(somenumbers,lo=-1,hi=1) elascer(somenumbers,mn=-10,mx=101,lo=-1,hi=4) # Works on numeric objects somenumbers <- cbind(c(-5,100,sqrt(2)),c(exp(1),0,-pi)) elascer(somenumbers) elascer(somenumbers,mn=-100) # Values < mn will return < lo (default=0) # Values > mx will return > hi (default=1) elascer(somenumbers,mn=-1,mx=99) elascer(somenumbers,lo=-1,hi=1) elascer(somenumbers,mn=-10,mx=101,lo=-1,hi=4) ```

ManyLabsOpenScience/manylabRs documentation built on April 12, 2018, 8:22 p.m.