scale_quantile: Cut off outer quantiles and rescale to a [0, 1] range

Description Usage Arguments Value Examples

View source: R/scaling.R

Description

Cut off outer quantiles and rescale to a [0, 1] range

Usage

1
scale_quantile(x, outlier_cutoff = 0.05)

Arguments

x

A numeric vector, matrix or data frame.

outlier_cutoff

The quantile cutoff for outliers (default 0.05).

Value

The centered, scaled matrix or vector. The numeric centering and scalings used are returned as attributes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Generate a matrix from a normal distribution
## with a large standard deviation, centered at c(5, 5)
x <- matrix(rnorm(200*2, sd = 10, mean = 5), ncol = 2)

## Scale the dataset between [0,1]
x_scaled <- scale_quantile(x)

## Plot rescaled data
plot(x_scaled)

## Show ranges of each column
apply(x_scaled, 2, range)

Example output

     [,1] [,2]
[1,]    0    0
[2,]    1    1

dynutils documentation built on March 22, 2021, 5:06 p.m.