So I have data in form (in real data I have more rows, of course so this is just a sample)
>df <- structure(list(cake.eated = c(1, 0, 0, 1, 1, 1), is.it.weekend = c(1, 1, 1, 0, 1, 0)),
+ .Names = c("is.cake.eated","is.it.weekend"), row.names = c(NA, -6L), class = "data.frame")
>df
is.cake.eated is.it.weekend
1 1
0 1
0 1
1 0
1 1
1 0
and I woulf like to perfotm Fisher's test to it. In contigency-table form my data looks like
>c = matrix(c(2205,2605,1442,1042), ncol=2)
>rownames(c) <- c("cake.eated", "cake.not.eated")
>colnames(c) <- c("not.weekend", "weekend")
>c
not.weekend weekend
cake.eated 2205 1442
cake.not.eated 2605 1042
So my question is, which one of these is the right way to use Fisher's test in R;
> fisher.test(c)
Fisher's Exact Test for Count Data
data: c
p-value < 2.2e-16
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.5539554 0.6753183
sample estimates:
odds ratio
0.6117068
OR
>fisher.test(df$is.cake.eated, df$is.it.weekend)
Fisher's Exact Test for Count Data
data: df$is.cake.eated and df$is.it.weekend
p-value = 1
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.8607512 1.1611740
sample estimates:
odds ratio
1
Is Fisher test even okay to use in this case an this kind of data or is some else like chi-squared better? Why are the results from fisher tests so different and what am I doing wrong?
> chisq.test(df$is.cake.eated, df$is.it.weekend)
Pearson's Chi-squared test with Yates' continuity correction
data: df$is.cake.eated and df$is.it.weekend
X-squared = 1.781e-06, df = 1, p-value = 0.9989
Also, by Barnard test my results look like
> barnard.test(2205, 1442, 2605, 1042, dp=0.01)
Barnard's Unconditional Test
Treatment I Treatment II
Outcome I 2205 1442
Outcome II 2605 1042
Null hypothesis: Treatments have no effect on the outcomes
Score statistic = 9.88313
Nuisance parameter = 0.03 (One sided), 0.97 (Two sided)
P-value = 7.65658e-22 (One sided), 7.65658e-22 (Two sided)
rain.zeros
data come from (where you runfisher.test(df$is.cake.eated, df$is.it.weekend)
the output data does not match the input.) $\endgroup$