2013-04-11 44 views
2

我目前正在爲學校,我需要從按地區劃分的每個狀態%未投保司機跑單因素方差分析的項目。我試圖從表中刪除NA,但遇到了麻煩。在數據表中刪除NA的單因素方差分析

> motor 
MW NE SE W 
1 0.11 0.09 0.25 0.16 
2 0.13 0.11 0.20 0.16 
3 0.12 0.04 0.13 0.22 
4 0.10 0.07 0.10 0.32 
5 0.09 0.09 0.08 0.10 
6 0.13 0.15 0.16 0.08 
7 0.12 0.07 0.25 0.09 
8 0.13 0.09 0.06 0.15 
9 0.07 0.11 0.28 0.30 
10 0.07 0.09 0.18 0.12 
11 0.13 NA 0.12 0.09 
12 0.17 NA 0.21 0.15 
13 0.06 NA NA 0.07 
14 0.18 NA NA NA 
15 0.08 NA NA NA 
16 0.11 NA NA NA 

> aov(motor) 
Error in terms.default(formula, "Error") : 
    no terms component nor attribute 

我使用na.omit,complete.cases和na.rm試過,但我的數據的任何部分被拆除或我收到同樣的錯誤消息。我也曾嘗試

summary(lm(motor)) 

這給了我一個0.77的P值,這是從P值在Excel(P = 0.007859928)

運行數據時,我收到了,我知道我不同我只是想念一些小事,但已經試圖尋找最後兩個小時找不到它。

任何人都可以幫忙嗎?

回答

1

惠, 公式是不好的,你需要有一列因素(司機的爲例),並繪製。您的數據中缺少此列。 Supose包含此欄 「司機」

motorist<-c("A","B","C","B","B","B","B","A","A","A","A","C","C","A","B","C") 
motor<-cbind(motorist,motor) 
aov(w~motorist,motor) 

將工作