[R] Most often pairs of chars across grouping variable

From: <svga_at_arcor.de>
Date: Tue, 29 Jul 2008 16:51:17 +0200 (CEST)

Hi list,

is there a package or function to compute the frequencies of pairs of chars in a variable across a grouping variable? Eg:

d <- data.frame(ID=gl(2,3), F=c("A","B","C","A","C","D"))
> d

  ID F
1 1 A
2 1 B
3 1 C
4 2 A
5 2 C
6 2 D

Now I want to summarize the frequencies of all pairs A-B, A-C, A-D, B-C, B-D, C-D across ID:

   A B C D

A  - 1 2 1
B  - - 1 0
C  - - - 1

here, the combination A-C is most frequent. The real problem behind that is that 'F' codes diagnoses and I search for the most often pairs of diagnoses.

Thanks, Sven

R-help_at_r-project.org 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 Tue 29 Jul 2008 - 14:54:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jul 2008 - 15:32:46 GMT.

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

list of date sections of archive