[問題] R的tapply函數 和殘差分析
用R做殘差分析的問題
資料結構: (整筆資料叫Adap)
age glucose_consentration .... Result
21 125 1
23 83 0
25 94 0
(以下省略)
....
目標:
我想對Result分別為0和1的資料做t.test 檢查其glucose concentraion是否顯著差異
在這之前要先診斷資料是否符合常態假設
做法:
resultf <-factor(Adap$Result) #對result 做factor
tapply(Adap$Glucose, resultf, resid) #殘差分析
tapply(Adap$Glucose, resultf, qqnorm) #畫QQ plot
問題:
原以為使用tapply指令畫qq plot會自動跑出兩張圖 一張是result為0的資料
一張是result為1的資料 結果只有一張@@
而resid函數跑不出來 log顯示
"錯誤在object$na.action : $ operator is invalid for atomic vectors"
請問我的做法哪裡錯了@@
該如何解決?
先謝謝大家!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.220.137
→
01/10 20:11, , 1F
01/10 20:11, 1F
→
01/10 20:20, , 2F
01/10 20:20, 2F
→
01/10 20:21, , 3F
01/10 20:21, 3F
→
01/10 21:04, , 4F
01/10 21:04, 4F
→
01/10 21:04, , 5F
01/10 21:04, 5F