Appending Frequency Tables - With Missing Values

后端 未结 3 1452
面向向阳花
面向向阳花 2021-01-23 05:44

The goal is to produce a frequency table of all my selected variables (about reading habits for 4 Newspapers) which in essence have the same possible values:

1=         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-23 06:14

    You could use mtabulate from qdapTools

    library(qdapTools)
    t(mtabulate(list(a,b,d,e)))
    #  [,1] [,2] [,3] [,4]
    #0    0    2    5    0
    #1    2    1    0    0
    #2    2    2    2    0
    #3    4    3    2   10
    #4    2    2    1    0
    

    Or

    t(mtabulate(data.frame(a,b,d,e)))
    #  a b d  e
    #0 0 2 5  0
    #1 2 1 0  0
    #2 2 2 2  0
    #3 4 3 2 10
    #4 2 2 1  0
    

提交回复
热议问题