2011-06-07 33 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)

相關問題