If you are looking for a function to standardize a variable so that it has mean zero and unit variance:
std=function(x){if(length(which(is.na(x)))==0) (x-mean(x))/sd(x) else (x-mean(x,na.rm=T))/sd(x,na.rm=T) } x=rnorm(100,3,5) mean(x) sd(x) x2=std(x) mean(x2) sd(x2) HTH, Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Ursprüngliche Nachricht----- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Gundala Viswanath Gesendet: Monday, September 07, 2009 11:24 PM An: r-h...@stat.math.ethz.ch Betreff: [R] Function to Normalize Numerical Vector in R Is there any? - G.V. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.