【发布时间】:2018-05-09 17:35:23
【问题描述】:
t.test(antibioticdata$Bacteria,
antibioticdata$Inhibition,
alternative = c("two.sided"),
paired = FALSE,
var.equal = FALSE)
这是我的 R 代码,用于对一组关于细菌抗生素耐药性的数据进行 t 检验。这给了我错误代码:
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) : argument is not numeric or logical: returning NA
2: In 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.
不知道我做错了什么
【问题讨论】:
-
您能否提供一个重现此问题的最小输入数据集(最小重现)?这可能有助于故障排除。
-
我相信这为正在发生的事情提供了线索:
Calling var(x) on a factor x。如果Bacteria或Inhibition之一是一个因素,则将发生错误和警告。 -
请查看可能重复的链接,这可能会回答您的问题。
-
请给minimal reproducible example,虽然错误信息很清楚。您是否有意对分类数据使用 t 检验?由于分类值不是正态分布的,甚至没有有意义的均值或方差,因此不清楚您希望通过运行测试发现什么。也许 R 只是在保护您免受统计废话的影响。 “不确定我做错了什么”的答案可能是“尝试对分类数据进行 t 检验”。
标签: r