我正在对数据集执行一种方差分析,并且在此处显示一些行:-
Number Call Weight
1 X 33.29
2 Y 88.22
3 Y 70.19
4 Y 69.25
5 X 73.26
6 X 56.18
7 Y 16.19
8 Y 20.21
9 Y 50.26
10 X 95.29
我使用以下方法进行了方差分析:-
aov <- aov(data$Weight ~ data$Call)
但是它没有给出任何p值。我也得到:-
Warning messages:
1: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
答案 0 :(得分:1)
我已经在这些数据上尝试过您的代码,并且可以正常工作。尝试检查str
的数据。最可能的问题是,Weight
是您所用的因素,您需要使用as.numeric()
将其更改为数字。
dta <- read.table(text=
"Number, Call, Weight
1, X, 33.29
2, Y, 88.22
3, Y, 70.19
4, Y, 69.25
5, X, 73.26
6, X, 56.18
7, Y, 16.19
8, Y, 20.21
9, Y, 50.26
1,0 X, 95.29", header=T, sep=",")
summary(aov(dta$Weight ~ dta$Call))
结果
Call:
aov(formula = dta$Weight ~ dta$Call)
Terms:
dta$Call Residuals
Sum of Squares 352.450 6303.466
Deg. of Freedom 1 8
Residual standard error: 28.07015
Estimated effects may be unbalanced
str(dta)
的结果
'data.frame': 10 obs. of 3 variables:
$ Number: int 1 2 3 4 5 6 7 8 9 1
$ Call : Factor w/ 3 levels " X"," Y",..: 1 2 2 2 1 1 2 2 2 3
$ Weight: num 33.3 88.2 70.2 69.2 73.3 ...