I have this solution which allows me to look at values of my type column individually in a fisher test. (can also swap out fisher for chisq.test)
But i tried to apply this to an anova test and had errors.
This is my original version
# fisher test status on types individually
fish = lapply(unique(df$type),function(i){
ctest = fisher.test(table(df$type == i, df$status))
data.frame(type = i, pvalue = ctest$p.value)
})
And i get this output which is my same desired output for an anova test
type pvalue
warning 7.94658438e-23
noncontact 5.84265922e-01
issue 4.18245681e-04
success 1.67653259e-09
This is an attempt I tried for anova test but got this error
anov = lapply(unique(df$numtype),function(i){
atest = aov(table(df$numtype == i ~ df$status))
data.frame(numtype = i, pvalue = atest$p.value)
})
Error: unique() applies to only vectors
And I am using a dataframe, which i didn't think would be a problem.
My columns used are like this (numeric columns only intended for anova ofcourse)
afluence | type | numtype | status |
---|---|---|---|
1 | noncontact | 1 | positive |
2 | warning | 2 | declined |
3 | issue | 3 | positive |
4 | success | 4 | positive |
5 | success | 1 | NA |
6 | success | 5 | positive |
Does anyone know how to make this work for an anova test?