Standardization
In statistics, standardization plays a crucial role as we have various attributes for modeling and all of them have different scales. So for comparison purposes, we need to standardize the variables to bring them on the same scale. Centering the values and creating the z
scores is done in R by the scale()
function. It takes the following arguments:
x
: A numeric objectcenter
: IfTRUE
, the object's column means are subtracted from the values in those columns (ignoring NAs); ifFALSE
, centering is not performedscale
: IfTRUE
, the centered column values are divided by the column's standard deviation (when center is alsoTRUE
; otherwise, the root mean square is used); ifFALSE
, scaling is not performed
If we want to center the data of Volume
in our dataset, we just need to execute the following code:
>scale(Sampledata$Volume, center=TRUE, scale=FALSE)
If we want to standardize the data of volume in our dataset, we just need to execute the following code:
>scale(Sampledata...