2011-06-07 35 views
19

可能重复:
R, correlation: is there a func that converts a vector of nums to a vector of standard units我可以用R计算z分数吗?

通过阅读计算器的评论,我发现,z分数可能与Python或Perl来计算的,但我没有遇到任何的R呢。我错过了吗?可以用R来完成吗?

由于(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. 

我相信我们有专门为这个R封装?我们可以在哪里找到它们?或类似的正常化包?

+1

重复:http://stackoverflow.com/questions/6148050/creating-z-scores http://stackoverflow.com/questions/5835545/r-correlation-is-there- a-func-that-c​​onvert-a-vector-of-a-vector-of-sta/5835599 – 2011-06-07 09:57:29

+3

Simon Blomberg:这是R.没有if。只有如何。 - 'fortune(“simon blomberg”)' – 2011-06-07 10:26:04

+0

为什么'pnorm(x,μ,σ)'是一个解决方案? – 2015-01-14 19:05:30

回答

42

if x是一个向量与原始分数然后scale(x)是一个向量与标准化的分数。

或手动:(x-mean(x))/sd(x)

相关问题