Can I calculate z-score with R?

a83 picture a83 · Jun 7, 2011 · Viewed 151.4k times · Source

Possible Duplicate:
R, correlation: is there a func that converts a vector of nums to a vector of standard units

By reading stackoverflow's comments, I found z-score maybe calculated with Python or perl, but I did not comes across any for R yet. Did I miss it? Is it possible to be done with R?

As (http://en.wikipedia.org/wiki/Standard_score.)

z-score = (x-μ)/σ

x is a raw score to be standardized; 
μ is the mean of the population; 
σ is the standard deviation of the population. 

I believe there are R packages designed for this? Where can we found them? Or similar package for normalization?

Answer

Sacha Epskamp picture Sacha Epskamp · Jun 7, 2011

if x is a vector with raw scores then scale(x) is a vector with standardized scores.

Or manually: (x-mean(x))/sd(x)