我有这样的数据集:
df<-data.frame(ID=c(1:5),P1=c("A","A","A","B","B"),P2=c("T","T","C","N","R"),P3=c("G","G","G","B","B"),A1=c("Present","Present","Present","absent","absent"),
B1=c("absent","Present","Present","absent","absent"),C1=c("absent","absent","Present","absent","absent") )
df
我想执行Fisher精确检验,这样我就可以用A1、B1、C1检验P1,然后用A1、B1、C1检验P2,再用A1、B1、C1检验P3。
fisher<-with(df, table(P1, A1))
fisher
fisher_test(fisher)
我有大的数据集,所以如果你能帮助我,请在一个代码将是伟大的。我知道如何测试对A1,B1和C1的P1,但我不能用相同的代码为P2和P3。任何帮助,不胜感激。
1条答案
按热度按时间tzdcorbm1#
一个使用
broom::tidy
的解决方案,用于在 Dataframe 中轻松表示测试结果。