Added grouping.calculation utility function for R

Help grouping calculation in R scripts