split_by function

Split or count the data according to certain factors