Skip to content
Prev 315090 / 398506 Next

count combined occurrences of categories

On Jan 11, 2013, at 2:54 AM, Biau David wrote:

            
You should first abandon the practice of using `cbind` inside  
`data.frame`. Obscure errors will plague your R experience until you  
do so.

Bas solution:

 > tutus <- data.frame(nam=tutu$nam, au=with(tutu, c(au1,au2,au3)))
 > tutab <- with(tutus, table(nam, au)  )
 > tutab
     au
nam  1 2 3 4 5 6 7
   da 2 3 1 2 4 0 0
   fr 2 2 2 2 2 1 1
   ya 1 2 1 1 0 1 0