do.L: Perform L-Normalization on a Vector

View source: R/do.L.R

do.LR Documentation

Perform L-Normalization on a Vector

Description

Standardizes all values in a vector to the unit vector ([0,1]) using local min and max

Usage

do.L(v, fun = range, na.rm = T)

Arguments

v

a vector of values

fun

a function that will return the minimum and maximum values to use to scale v; defaults to range

na.rm

Logical: should NA be removed? defaults to TRUE

Details

This is an alternative to performing a L normalization over the full matrix. if the minimum and the maximum values returned after applying fun are the same, do.L will return 0.

Value

A vector of values of the same length as x, scaled to the unit vector.

Author(s)

Yann Abraham

Examples

data(iris)
mat <- iris[,c('Sepal.Length','Sepal.Width','Petal.Length','Petal.Width')]
scaled <- apply(mat,2,do.L)
summary(scaled) # all values are between [0,1]

scaled2 <- apply(mat,2,do.L,fun=function(x) quantile(x,c(0.025,0.975)))
summary(scaled2) # all values are between [0,1]

plot(scaled,scaled2,
     col=rep(seq(1,ncol(scaled)),each=nrow(scaled)),
     pch=16)
legend('topleft',legend=dimnames(scaled)[[2]],col=seq(1,ncol(scaled)),pch=16,bty='n')


yannabraham/Radviz documentation built on April 3, 2022, 1:30 p.m.