[R] Converting tables to matrices

Michael Bedward michael.bedward at gmail.com
Fri Sep 17 07:04:05 CEST 2010


Oops, that should have been result[[1]], not results[[1]]

On 17 September 2010 15:03, Michael Bedward <michael.bedward at gmail.com> wrote:
> Hello Selthy,
>
> Here's one way. Assume your tables are called x.trt and x.cont
>
> # form a single matrix
> x <- cbind(x.trt, x.cont)
> colnames(x) <- c("Ntrt", "BPtrt", "Ncon", "BPcon")
> result <- apply( x, 1, function(xrow) fisher.test( matrix(xrow, nrow=2) ) )
>
> Now result is a list where element i holds the test results for row i
> of your data. E.g. to get the results for row 1..
>
> results[[1]]
>
> Michael



More information about the R-help mailing list