【发布时间】:2018-08-02 10:34:40
【问题描述】:
嘿,伙计们,我正在尝试进行 t 检验,但看起来有问题... 数据如下:
pot pair type height
I 1 Cross 23,5
I 1 Self 17,375
I 2 Cross 12
I 2 Self 20,375
我进行了 t 检验:
darwin <- read.table("darwin.txt", header=T)
plot(darwin$type, darwin$height, ylab="Height")
darwin.no.outlier = subset(darwin, height>13)
tapply(darwin.no.outlier$height, darwin.no.outlier$type, var)
t.test(darwin$height ~ darwin$type)
R 给我的错误如下:
错误
if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
另外:警告信息:
1:在 mean.default(x) 中:argument is not numeric or logical: returning NA
2:在 var(x) 中:
Calling var(x) on a factor x is deprecated and will become an error.
Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
3:在 mean.default(y) 中:argument is not numeric or logical: returning NA
4:在 var(y) 中:
Calling var(x) on a factor x is deprecated and will become an error.
Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
【问题讨论】:
-
确保您的
height变量是数字。好像不是。 -
试试
t.test(height ~ type, data=darwin) -
@Jimbou 我想他会得到同样的错误。
height中的逗号表明它不是数字变量。更多信息:stackoverflow.com/questions/3247178/…