Count occurrences of factor in R, with zero counts reported

前端 未结 5 1659
死守一世寂寞
死守一世寂寞 2021-02-07 23:58

I want to count the number of occurrences of a factor in a data frame. For example, to count the number of events of a given type in the code below:

library(plyr         


        
5条回答
  •  面向向阳花
    2021-02-08 00:38

    In data you put your dataframe and into levels your categories.

    table(factor(data, levels = 1:5)) 
    

提交回复
热议问题