An efficient way of Normalizing values is through the Min-Max Scaling method.
With Min-Max Scaling, I scale the data values between a range of 0 to 1 only. Due to this, the effect of outliers on the data values suppresses to a certain extent. Moreover, it helps us have a smaller value of the standard deviation of the data scale.
In the below example, I have used ‘caret’ library to pre-process and scale the data. The preProcess() function enables us to scale the value to a range of 0 to 1 using method = c('range') as an argument. The predict() method applies the actions of the preProcess() function on the entire data frame as shown below.
rm(list = ls())
data = c(1200,34567,3456,12,3456,0985,1211)
library(caret)
process <- preProcess(as.data.frame(data), method="range")
norm_scale <- predict(process, as.data.frame(data))
Output:
data
1 0.03437997
2 1.00000000
3 0.09966720
4 0.00000000
5 0.09966720
6 0.02815801
7 0.03469831