To implement the center and scaling function from caret package using R programming.
Centering and scaling will work forcontinuous data.
To scale the data, each predictor valueisdivided by its standard deviation(sd).
This helps in coercing the predictor valueto have a sdof one.
To center a predictor variable,the averagepredictor value is subtractedfrom allthe values.
As a result of centering, the predictorhas zero mean.
R Package : caret
R Function : scale(x, scale =, center = )
x -- a Numeric Vector
scale -- logical value
center -- logical value
#Centering and Scaling
#install.packages(“caret”)
library(“caret”)
#Input
x<-mtcars$disp
#Scale Value
scale(x,scale=TRUE,center =FALSE)
#Center Value
scale(x , scale = FALSE, center= TRUE)
#Both Scale and Center Value using Scale Function
scale(x, scale = TRUE, center = TRUE)