box.outliers: Box Outliers

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/box.outliers.R

Description

Squeeze all outliers onto standard.dev-limits and/or normalize to [0;1] scale

Usage

1
box.outliers(x, limit = 1.5, normalize = TRUE)

Arguments

x

numeric vector, matrix, array, data.frame

limit

limit(SD,standard deviation) any number deviating more than limit from mean is an outlier

normalize

TRUE/FALSE should output range be normalized to [0;1]?

Details

Can be used to squeeze high dimensional data into a box, hence the name box.outliers. Box.outliers is used internally in forestFloor-package to compute colour gradients without assigning unique colours to few outliers. It's a box because the borders uni-variate/non-interacting.

Value

matrix(n x p) of normalized values

Author(s)

Soren Havelund Welling, 2014

See Also

scale()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
box.outliers = function (x, limit = 1.5)  {
  x = scale(x)
  x[ x > limit] =  limit
  x[-x > limit] = -limit
  x = x - min(x)
  x = x/(limit * 2)
  return(x)
}
n=1000 #some observations
p = 5  #some dimensions
X = data.frame(replicate(p,rnorm(n))) # a dataset
Xboxed =box.outliers(X,limit=1.5) #applying normalization
plot(Xboxed[,1],Xboxed[,2],col="#00000088") #plot output for first two dimensions

sorhawell/forestFloor documentation built on Oct. 23, 2021, 2:20 a.m.