Data:
variant disease control total
A1         1      53    54
A2         6      2     8
A3         15     37    52
A4         0      53    53
A5         65     4     69
A6         4      5     9
A7         3      34    37
I would like to add a row at the bottom with column totals for the disease and control ones and then run a fishers per row adding another column with p-values from the test.
Desired outcome (p-values made up):
variant disease control total p-value
A1         1      53    54    0.001
A2         6      2     8     0.6921
A3         15     37    52    1
A4         0      53    53    0.98
A5         65     4     69    0.68
A6         4      5     9     0.63
A7         3      34    37    0.832
C_total    94     188
I've tried:
rbind(df, colSums(df[,2:3]), fill=TRUE) 
But this give me all the column totals in the final two columns
Not sure about the Fishers yet but imagine some form of apply function using per row and per total to create a 2x2 table.
Many thanks
                        
One
dplyrandtibblesolution could be:And as I suppose you try to compare whether the count of individuals between the two groups is the same, a chi-square goodness of fit test could be used.