我想测试在有或没有疫苗的病毒(组成)中存活的啮齿动物数量之间是否存在关联。这是我的数据:
Treatment Number of deaths Number of Survivors
Vaccinated 11 36
not vaccinated 24 26
以下我如何将其输入R:
dframe1 <- read.csv(file.choose())
names(dframe1)
# [1] "Treatment" "Number.of.deaths" "Number.of.survivors"
count <- table (dframe1$Number.of.deaths, dframe1$Number.of.survivors)
count
# 26 36
# 11 0 1
# 24 1 0
chisq.test(count)
# Pearson's Chi-squared test with Yates' continuity correction
#
# data: count
# X-squared = 0, df = 1, p-value = 1
# Warning message:
# In chisq.test(count) : Chi-squared approximation may be incorrect
我是否正确完成了这项工作?
如果没有,请帮忙。 欢呼声。
答案 0 :(得分:1)
您需要将感兴趣的值放在表中,而不是像这样的行和列名称:
count <- data.frame(dframe1$Number.of.deaths, dframe1$Number.of.survivors)
当您运行关联的卡方检验时,您现在应该得到以下输出:
chisq.test(count)
# Pearson's Chi-squared test with Yates' continuity correction
# data: count
# X-squared = 5.3331, df = 1, p-value = 0.02092