When invoked in the preceding example, the scale() function computes the standard z score for each value (ignoring NAs) of each variable. That is, from each value it subtracts the mean and divides the result by the standard deviation of the associated variable.
The scale() function takes two optional arguments, center and scale, whose default values are TRUE. The following table shows the effect of these arguments:
Argument |
Effect |
center = TRUE, scale = TRUE |
Default behavior described earlier |
center = TRUE, scale = FALSE |
From each value, subtract the mean of the concerned variable |
center = FALSE, scale = TRUE |
Divide each value by the root mean square of the associated variable, where root mean square ... |