 This is a quick tip about making nested data frames in R. Nest groups of data frames in a table so you can use the per map functions to iterate over these lists of data frames. I find this process is simpler and computationally more efficient than composing for loops. In this video series, I explain how to use the per map functions to iterate custom functions over data frames. The series will become progressively more fluent in data wrangling examples, but here I show a building block data wrangling tip that will help you leverage R as a functional programming language. As always, see the video description for a link to the code in the GitHub repository. What you see in the code chunk that begins on line 18 is a piped data sentence that will nest a data frame by a grouping variable. It's often convenient to proceed the nest function with the group by function as you see in line 20 and 21. But as you see in line 29, group by is not always necessary. Notice how the tables are nested by gender, the grouping category. Let's put this in action. Once nested, it's convenient and efficient to use the mutate and the map functions as a means of iterating functions over each table within the grouping. In line 37, I'll compose a function to make a scatter plot. You can watch the previous lesson on custom functions to learn more about composing functions. In line 45, I iterate my plot making functions over each group. The result is a list column of ggplot2 objects. In line 46, if I wanted to see the plots, I can pull the object from the newly mutated My Plots variable in the parent table. One challenge with iterating over nested objects, particular to ggplot2 objects derived from groups of nested tables, is that I always want to incorporate a value from the parent table into the title of the nested plot object. In line 56, I take a second pass at the My Plots variable using an anonymous function to iterate the group values into the plot title. Now you've seen a demonstration of iterating over nested tables. Let's go further and iterate a linear model over the same nested grouping of tables. Even new through line 69, but beginning in line 70, I can map the linear model as an anonymous function. Then in line 71, I use the BroomTidy function to transform the model data type and store it as a nested table. In line 72, I unnest the model to see the results. Note, there are more variables in the model off the right hand side of the visible screen. So now that all the modeling results are part of a table, I can use standard tidyverse packages and functions to further manipulate my model. For more advanced examples, stay tuned for later videos where I demonstrate regex, pivot longer, and iterating with custom functions.