R has a library called plyr for a split-apply-combine data analysis. The plyr library has a function called ddply, which can be used to apply a function to a subset of a DataFrame, and then combine the results into another DataFrame.
For more information on ddply, you can refer to the following link: http://www.inside-r.org/packages/cran/plyr/docs/ddply.
To illustrate, let's consider a subset of a recently created dataset in R, which contains data on flights departing NYC in 2013: http://cran.r-project.org/web/packages/nycflights13/index.html.