calc_counts function

Calculate counts of a categorical variable