Skip to content
Prev 77514 / 398502 Next

scale function within a for-loop?

Hi Petr,

you are right scale() will produce the standardized version of the 
matrix as documented; a note though, for columns means and standard 
deviations it's better to use colMeans() and sd() directly instead of 
apply(mat, 2, mean) and apply(mat, 2, sd), i.e.,

sc.mat <- scale(as.matrix(kalcin[, 3:7]))

colMeans(sc.mat)
sd(sc.mat)


Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Petr Pikal" <petr.pikal at precheza.cz>
To: "Frank Schmid" <frank.schmid at vwi.unibe.ch>; 
<r-help at stat.math.ethz.ch>
Sent: Tuesday, September 20, 2005 10:39 AM
Subject: Re: [R] scale function within a for-loop?
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm