I am trying to figure out a way to subset a data set using certain criteria stored in rows and generate reports for each rows. Below is a minimal example where I calculate the average mpg for certain cyl and gear combination in the mtcars data.
Here I used slice to select one row for the subsetting criteria. I figure that one of the map functions should allow me to generate a list of the mpg_summary for multiple rows, but could not find anything. Your advice is appreciated.
Thanks! group_nest is nice, it generated the list of the data frame that I want.
I do not use your second approach since I have complex/expensive calculation in the summary/reporting function (mpg_summary here) and multiple dataframes are involved.