Re: [R] Converting tables to matrices

2010-09-20 Thread Ivan Calandra
Hi, In this case, str() would help you a lot too to understand the structure of your ft object, and especially which element contains what. Ivan Le 9/20/2010 04:59, Michael Bedward a écrit : > A good function to know about is names(). For example... > > ft<- fisher.test( my.data ) > names(ft)

Re: [R] Converting tables to matrices

2010-09-19 Thread Michael Bedward
A good function to know about is names(). For example... ft <- fisher.test( my.data ) names(ft) Produces the following listing... [1] "p.value" "conf.int""estimate""null.value" "alternative" "method" "data.name" You can then access any of those attributes with the "$" operator

Re: [R] Converting tables to matrices

2010-09-19 Thread selthy
Great! I'm loving this forum. I'm slowly teaching myself the basics of R, but in the meantime this is saving me a lot of time in the data analysis phase (I'm a molecular biologist). Thanks again! -- View this message in context: http://r.789695.n4.nabble.com/Converting-tables-to-matrices-tp25433

Re: [R] Converting tables to matrices

2010-09-19 Thread Michael Bedward
Hi Luke, Easy-peasy... If you have... result <- fisher.test( some_data ) Then you can get the probability with... result$p.value So in your case just modify the apply statement in the previous post to... pvalues <- apply( x, 1, function(xrow) fisher.test( matrix(xrow, nrow=2) )$p.value ) Mi

Re: [R] Converting tables to matrices

2010-09-19 Thread selthy
Hi Michael, I have another simple question which I'm sure you could help me with. How do I extract only the p values from "result" (i.e. all of the p values from the i tests, preferably in a single column of data)? I've read over the fisher.test help (http://127.0.0.1:16311/library/stats/html/fis

Re: [R] Converting tables to matrices

2010-09-16 Thread selthy
Thanks so much! I realise that probably seems very simple to you, but you've just saved me hours of struggling with syntax and commands I'm not very familiar with...excellent. Cheers, Selthy -- View this message in context: http://r.789695.n4.nabble.com/Converting-tables-to-matrices-tp2543309p25

Re: [R] Converting tables to matrices

2010-09-16 Thread Michael Bedward
Oops, that should have been result[[1]], not results[[1]] On 17 September 2010 15:03, Michael Bedward 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

Re: [R] Converting tables to matrices

2010-09-16 Thread Michael Bedward
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

[R] Converting tables to matrices

2010-09-16 Thread selthy
Hi there, I'm a real beginner to R. I have two tables of the following format (~1000 rows in each): Table 1 (experimental) Nbp 1064 12312089 856 12312234 Table 2 (control) 846334728908 879 34443290 . I would like to do Fisher's exact tests comparing each row of th