Skip to content

Joining two (or more) frequency tables

3 messages · Jan.Sunde at biokapital.no, jim holtman, Wu Gong

#
use the 'reshape package:
Loading required package: reshape
Loading required package: plyr
father.id diagnosis diagnosis2 diagnosis3
1         a       100        200        300
2         b       200        100        340
Using father.id as id variables
  father.id   variable value
1         a  diagnosis   100
2         b  diagnosis   200
3         a diagnosis2   200
4         b diagnosis2   100
5         a diagnosis3   300
6         b diagnosis3   340
Using father.id as id variables
100 200 300 340
  a   1   1   1   0
  b   1   1   0   1

        
On Wed, May 19, 2010 at 5:56 AM, <Jan.Sunde at biokapital.no> wrote:

  
    
#
+ diagnosis = sample(c(100,200,300,340),5,replace=TRUE),
+ diagnosis1 = sample(c(100,200,300,340),5,replace=TRUE),
+ diagnosis2 = sample(c(100,200,300,340),5,replace=TRUE))
father.id diagnosis diagnosis1 diagnosis2
1         a       340        100        300
2         b       200        300        340
3         c       200        300        100
4         d       200        100        300
5         e       200        100        100
father.id father.id.1 father.id.2
[1,] "a"       "a"         "a"        
[2,] "b"       "b"         "b"        
[3,] "c"       "c"         "c"        
[4,] "d"       "d"         "d"        
[5,] "e"       "e"         "e"
match 100 200 300 340
    a   1   0   1   1
    b   0   1   1   1
    c   1   1   1   0
    d   1   1   1   0
    e   2   1   0   0
Please refer to:
http://r.789695.n4.nabble.com/Counting-Frequencies-in-Data-Frame-tt2221342.html#a2221487
http://r.789695.n4.nabble.com/Counting-Frequencies-in-Data-Frame-tt2221342.html#a2221487 

-----
A R learner.