Two questions:
-
Is there a function in R to generate ALL possible two-way contingency tables for given marginal frequencies? This could be programmed but maybe someone already did this, I hope.
-
Is there a function to obtain the probability (or the logarithm of that probability) of finding a given (observed, say) contingency table, with given margins, under the hypothesis of independence of the row and column variable?
Thanks for any help!
For both questions: I did not try to program this, because I would not be surprised if this is available in R already.