[R] A contingency table of counts by case

From: Serguei Kaniovski <kaniovsk_at_wifo.ac.at>
Date: Wed 19 Jul 2006 - 01:18:27 EST


Here is an example of the data.frame that I have,

df<-data.frame("case"=rep(1:5,each=9),"id"=rep(1:9,times=5),"x"=round(runif(length(rep(1:5,each=9)))))

"case" represents the cases,
"id" the persons, and
"x" is the binary state.

I would like to know in how many cases any two persons

  1. both have "1",
  2. the first has "0" - the second has "1",
  3. the first has "0" - the second has "0",
  4. both have "0".

There will be choose(9,2) sums, denoted s_ij for 1<=i<j<=9, where i and j are running indices for an "id"-pair.

Please help, this is way beyond my knowledge of R!

Thank you,
Serguei Kaniovski

-- 
___________________________________________________________________

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@wifo.ac.at

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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed Jul 19 01:35:25 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 19 Jul 2006 - 20:16:47 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.