Re: [R] list contingency tables

2018-11-09 Thread Bert Gunter
Yes, exactly (heh, heh). ?fisher.test is probably what is wanted. For arbitrary rxc tables with fixed marginals, this is a difficult problem. Mehta's efficient network algorithm to solve it can be found by a web search on "algorithm for Fisher exact test." -- Bert On Fri, Nov 9, 2018 at 12:3

Re: [R] list contingency tables

2018-11-09 Thread David Winsemius
Seems like you are trying to recreate the calculations needed to perform an exact test. Why not look at the code for that or even easier, just use the function. -- David. On 11/8/18 8:05 PM, li li wrote: Hi all, I am trying to list all the 4 by 2 tables with some fixed margins. For exa

Re: [R] list contingency tables

2018-11-09 Thread Jeff Newmiller
Don't give up on for loops entirely... some of the largest time savings in optimizing loops are achieved by managing memory effectively. [1] [1] https://www.r-bloggers.com/r-tip-use-vectormode-list-to-pre-allocate-lists On November 8, 2018 8:05:39 PM PST, li li wrote: >Hi all, > I am trying t

[R] list contingency tables

2018-11-08 Thread li li
Hi all, I am trying to list all the 4 by 2 tables with some fixed margins. For example, consider 4 by 2 tables with row margins 1,2,2,1 and column margins 3,3. I was able to do it using the code below. However, as seen below, I had to first count the total number of tables with the specific row