# Scaling the rows of a matrix

#### the_august

##### New Member
I'm facing a problem while scaling(z-transform) the row values of a numeric data matrix,using the following code:

Code:
rm(list=ls())
set.seed(12345)
my.mat <- matrix(rnorm(120,0,0.5),nrow=6,byrow=TRUE)
rownames(my.mat) <- paste("s",1:6,sep="")
colnames(my.mat) <- paste("g",1:20,sep="")
dim(my.mat)
# 6 20#six rows 20 columns
z.mat <- apply(my.mat, MARGIN = 1, FUN = scale )
dim(z.mat)
#20 6 # The matrix gets transposed##!!!!
to get the correct matrix for which all the row means equal zeo and std. deviation 1, I've to transpose t(z.mat) again. Is there something I'm missing ?

Thanks