[R] Reshape into a contingency table/Fisher's test

Serguei Kaniovski kaniovsk at wifo.ac.at
Tue Oct 3 15:03:43 CEST 2006


Dear all,

how can I "reshape"/"cast" the following matrix

00;01;10;11
John.Mike;123;313;12;31
John.Jim;54;57;39;36
John.Steve;135;47;47;74
Mike.Jim;63;37;27;16
Mike.Steve;15;15;5;61
Jim.Steve;6;10;34;35

into a set of stacked 2x2 contingency tables

0;1
John;123;12
Mike;313;31
John;54;39
Jim;57;36
John;135;47
Steve;47;16
...

so that the "fisher.test" and "chisq.test" can be "applied" to the
pairs of names. As as result I would like to have the original format, ie

John.Mike
John.Jim
John.Steve
Mike.Jim
Mike.Steve
Jim.Steve

with two columns containing the p-values of the tests.

Thanks a lot,
Serguei
--
___________________________________________________________________

Austrian Institute of Economic Research (WIFO)

Name: Serguei Kaniovski			P.O.Box 91
Tel.: +43-1-7982601-231			Arsenal Objekt 20
Fax:  +43-1-7989386			1103 Vienna, Austria
Mail: Serguei.Kaniovski at wifo.ac.at

http://www.wifo.ac.at/Serguei.Kaniovski



More information about the R-help mailing list