| scalewt {ade4} | R Documentation |
transforms a numeric matrix in a centred and scaled matrix for any weighting.
scalewt(X, wt = rep(1, nrow(X)), center = TRUE, scale = TRUE)
X |
a numeric matrix (like object) |
wt |
a vector of weighting |
center |
a logical value indicating whether the array should be centred |
scale |
a logical value indicating whether the array should be scaled |
returns a centred, scaled matrix
The norms are calculated with 1/n and the columns of null variance are still equal to zero.
Daniel Chessel
scalewt(matrix(1:12,4,3)) scale((matrix(1:12,4,3))) scale(matrix(1,4,3)) scalewt(matrix(1,4,3))
> library(ade4)
> ### Name: scalewt
> ### Title: Centring and Scaling a Matrix of Any Weighting
> ### Aliases: scalewt
> ### Keywords: utilities
>
> ### ** Examples
>
> scalewt(matrix(1:12,4,3))
[,1] [,2] [,3]
[1,] -1.3416408 -1.3416408 -1.3416408
[2,] -0.4472136 -0.4472136 -0.4472136
[3,] 0.4472136 0.4472136 0.4472136
[4,] 1.3416408 1.3416408 1.3416408
> scale((matrix(1:12,4,3)))
[,1] [,2] [,3]
[1,] -1.1618950 -1.1618950 -1.1618950
[2,] -0.3872983 -0.3872983 -0.3872983
[3,] 0.3872983 0.3872983 0.3872983
[4,] 1.1618950 1.1618950 1.1618950
attr(,"scaled:center")
[1] 2.5 6.5 10.5
attr(,"scaled:scale")
[1] 1.290994 1.290994 1.290994
> scale(matrix(1,4,3))
[,1] [,2] [,3]
[1,] NaN NaN NaN
[2,] NaN NaN NaN
[3,] NaN NaN NaN
[4,] NaN NaN NaN
attr(,"scaled:center")
[1] 1 1 1
attr(,"scaled:scale")
[1] 0 0 0
> scalewt(matrix(1,4,3))
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
[3,] 0 0 0
[4,] 0 0 0
>
>
>
>