It is almost obvious that there is a need to write customized functions to solve specialized problems. Though there are lots of built-in functions available in base R and also in the specialized libraries, you still might require some kind of output that is not available through the built-in functions. For example, you might want to create a new output dataset by taking only the regression coefficient from a series of linear regression models for the various unique combinations of other variables. In that case, you must write a customized function to achieve this task. The summarize() function from the dplyr library is a convenient way to calculate user-defined statistics. The problem with the summarize() function within the dplyr library is that it can only return single-valued outputs.
In this recipe, you will write a customized...