An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110401/47e86afd/attachment.pl>
Fisher's test
2 messages · Jim Silverton, Peter Ehlers
On 2011-04-01 10:19, Jim Silverton wrote:
I have a matrix with 2 columns and I want to do fishers exact test for these with the totals for each row being 100 say. The data has the form: 23 12 32 21 12 2 and these represents the tables: 23 12 77 88 32 21 78 79 12 2 88 98 How do I use apply to speed up aclculation of the fisher.exact test?
apply(yourMatrix, 1, function(x) fisher.test(cbind(x, 100 - x)))
or, if you only want the P-value:
apply(yourMatrix, 1,
function(x) fisher.test(cbind(x, 100 - x))$p.value)
Peter Ehlers