I'm still working on my project in R. My questionnaire's database consists of 39 variables, each of it with 20 Nominal responses. I'm creating 2 x 2 contingency tables for all the variables and, because the low sample number, willing to apply Fisher's Exact Test for Count Data.
Now, I'm trying to associate variable number 1 to the other 38. Then, Variable number 2 to the other 37, and so on.
I can do the contingency tables and Fisher's Exact Test for each, just like in the next code, but it's getting kinda monotonous.
Who_answers.age <- table(BD$Who_answers,BD$age, dnn = c("Who_answers","age"))
FT.Who_answers.age<-fisher.test(x = Who_answers.age, alternative = "two.sided")
FT.Who_answers.age$p.value
Who_answers.gender <- table(BD$Who_answers,BD$gender, dnn = c("Who_answers","gender"))
FT.Who_answers.gender<-fisher.test(x = Who_answers.gender, alternative = "two.sided")
FT.Who_answers.gender$p.value
Who_answers.diagnosis <- table(BD$Who_answers,BD$diagnosis, dnn = c("Who_answers","diagnosis"))
FT.Who_answers.diagnosis<-fisher.test(x = Who_answers.diagnosis, alternative = "two.sided")
FT.Who_answers.diagnosis$p.value
Who_answers.acomp_rutsu <- table(BD$Who_answers,BD$acomp_rutsu, dnn = c("Who_answers","acomp_rutsu"))
FT.Who_answers.acomp_rutsu<-fisher.test(x = Who_answers.acomp_rutsu, alternative = "two.sided")
FT.Who_answers.acomp_rutsu$p.value
Who_answers.Cuarto_propio <- table(BD$Who_answers,BD$Cuarto_propio, dnn = c("Who_answers","Cuarto_propio"))
FT.Who_answers.Cuarto_propio<-fisher.test(x = Who_answers.Cuarto_propio, alternative = "two.sided")
FT.Who_answers.Cuarto_propio$p.value
Who_answers.Duerme_con <- table(BD$Who_answers,BD$Duerme_con, dnn = c("Who_answers","Duerme_con"))
FT.Who_answers.Duerme_con<-fisher.test(x = Who_answers.Duerme_con, alternative = "two.sided")
FT.Who_answers.Duerme_con$p.value
Is there a way to code all those associations and their Fisher's Exact Test more easily?
As mentioned in my previous questions, I'm fairly new to R. Thank you so much for your help.
a purely technical answer; avoiding the issue of whether you should do this.