【发布时间】:2021-12-12 06:16:30
【问题描述】:
我的变量RaceCat在编码table(data$RaceCat)后看起来像这样
我想进行卡方检验,但我知道我需要摆脱美洲印第安人和中东人的种族,因为它们有 0。 American Indian 编码为 5,Middle Eastern 编码为 4。我的思考过程是做 data%>% filter(RaceCat!=5)%>% filter(RaceCat!=4)
但是,当我尝试这样做时,R 会说 length of 'dimnames' [2] not equal to array extent。
这是我尝试做的另一件事:
hivneg<-droplevels(hivneg)
a<- table(hivneg$RaceCat, hivneg$PrEP2)
chisq.test(a, correct=F)
但是,table() 和 chisq.test() 不会运行。它说
mapply 中的警告消息(FUN = f, ..., SIMPLIFY = FALSE): “更长的参数不是更短长度的倍数”
【问题讨论】:
-
这个种族变量是您预期的还是您观察到的?如果它是您观察到的一部分,则无需丢弃它。对于零值观察计数,卡方是明确定义的。
标签: r chi-squared