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