Frequency count of two column in R

后端 未结 7 938
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 03:37

I have two columns in data frame

2010  1
2010  1
2010  2
2010  2
2010  3
2011  1
2011  2

I want to count frequency of both columns and get

7条回答
  •  轮回少年
    2020-11-27 04:13

    library(data.table)
    
    oldformat <- data.table(oldformat)  ## your orignal data frame
    newformat <- oldformat[,list(Freq=length(m)), by=list(y,m)]
    

提交回复
热议问题