r - ANOVA 因子警告和无 p 值
问题描述
我正在为数据集做单向方差分析,我在这里显示了一些行:-
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
解决方案
我已经在这些数据上尝试了您的代码,并且它可以正常工作。尝试检查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 ...
推荐阅读
- python - 根据参数类型设置 issubset 性能差异
- .htaccess - 防止人们直接在我的网站上打开 pdf
- mysql - 编写为备份文件创建日期目录的小型 Shell 脚本时遇到问题
- perl - 在单次迭代中提取相同模式的第一次和最后一次出现之间的所有内容
- javascript - 如何使用javascript从summernote编辑器获取和设置光标位置
- ruby-on-rails - 如何在索引视图中显示图像
- javascript - 读取 xml 文件以确定复制哪些文件的 Grunt 构建脚本
- django-viewflow - Viewflow Django - 你如何弃用一个步骤?
- row - 向下行 - Java 脚本
- c++ - 如何获取由 CreateProcess 生成的进程的真实 ID