我有一個包含超過80000條記錄列聯表及以下大型CSV文件的第一條記錄:錯誤中的R pnorm - 「非數字的參數,以數學函數」
test = data.frame(a=1, b=0, c=1, d=2014, R1=1, R2=2015, C1=2, C2=2014,
n=2016, sampleMean=2015, popMean=2, sdErr=2015, tScore=0.999049881)
鑑於
z = p_cap - p/sqrt(p*(1-p)/n)
ie the observed mean minus the population mean over the standard error
。
test.stat = test$a/test$n - test$popMean/sqrt(test$sdErr)
其計算結果爲-0.04405856
。使用pnorm
函數來計算pValue
:
pValue = pnorm(test.stat, mean=test$sampleMean, sd=test$sdErr, lower.tail=TRUE)
。但我得到以下錯誤:
Non-numeric argument to mathematical function
當運行以下參數的命令,沒有錯誤:
pValue = pnorm(test.stat, mean=0, sd=1, lower.tail=TRUE)
pValue
[1] 0.4824289
是什麼錯誤的含義及如何避免呢?
爲了不用另一個問題發佈相同的數據,我對標準錯誤有疑問。它是否與標準偏差相同?在我的參考書中,標準誤差計算如下:test$a * sqrt(test$n)
感謝您提前給予的幫助!
爲編輯@ilanman感謝。 – Mohammed
如果您有兩個問題,最好問兩個問題。 –
@JeremyMiles我認爲重複相同的數據是多餘的。由於第二個問題與第一個問題的背景密切相關,我認爲可以這樣做。再次感謝。 – Mohammed