class: center, middle, inverse, title-slide # Nested Data --- --- ## Nested Data * A nested data frame stores individual tables within the cells of a larger, organizing table. * Use a nested data frame to: * preserve relationships between observations and subsets of data * manipulate many sub-tables at once with the purrr functions map(), map2(), or pmap(). <img src="myss/nestdata.png" width="70%" /> --- ### How to create a nested data frame: 1. Group the data frame into groups with dplyr::group_by() 2. Use nest() to create a nested data frame with one row per group ```r knitr::include_graphics("myss/nesteddata2.png") ``` <img src="myss/nesteddata2.png" width="70%" /> --- ### unnest() ```r knitr::include_graphics("myss/unnest.png") ``` <img src="myss/unnest.png" width="70%" /> --- ## List Columns ```r knitr::include_graphics("image/tb03_list-column/listcolumn.png") ``` <img src="image/tb03_list-column/listcolumn.png" width="1393" /> --- ## List Column Workflow ```r knitr::include_graphics("myss/listColumn2.png") ``` <img src="myss/listColumn2.png" width="100%" /> --- ## WORK WITH LIST COLUMNS ```r knitr::include_graphics("myss/workwithcolumnlist01.png") ``` <img src="myss/workwithcolumnlist01.png" width="1316" /> ```r knitr::include_graphics("myss/workwithcolumnlist02.png") ``` <img src="myss/workwithcolumnlist02.png" width="1331" /> ```r knitr::include_graphics("myss/workwithcolumnlist03.png") ``` <img src="myss/workwithcolumnlist03.png" width="1373" /> --- ```r knitr::include_graphics("image/tb03_list-column/mapLogic.png") ``` <img src="image/tb03_list-column/mapLogic.png" width="1363" /> --- ## Simplify the List column ```r knitr::include_graphics("image/tb03_list-column/mapWalk.png") ``` <img src="image/tb03_list-column/mapWalk.png" width="976" /> ---