class: center, middle, inverse, title-slide # Data Wrangling with R --- ## tidyr & dplyr Two packages to help you work with the structure of data. ```r knitr::include_graphics("image/tb01_data-wrangling/dplyr_cheatsheet.png") ``` <img src="image/tb01_data-wrangling/dplyr_cheatsheet.png" width="629" /> https://www.rstudio.com/resources/cheatsheets/ --- ```r knitr::include_graphics("image/tb01_data-wrangling/pipe.png") ``` <img src="image/tb01_data-wrangling/pipe.png" width="1229" /> --- Data sets come in many formats …but R prefers just one. --- ## pipe ```r knitr::include_graphics("image/tb01_data-wrangling/pipe.png") ``` <img src="image/tb01_data-wrangling/pipe.png" width="1229" /> --- ## tidy data ```r knitr::include_graphics("image/tb01_data-wrangling/tidy_data.png") ``` <img src="image/tb01_data-wrangling/tidy_data.png" width="1383" /> ### Examples: ```r knitr::include_graphics("image/tb01_data-wrangling/examples.png") ``` <img src="image/tb01_data-wrangling/examples.png" width="1383" /> --- ## tidyr A package that reshapes the layout of tables. Two main functions: gather() and spread() ### test ```r knitr::include_graphics("image/tb01_data-wrangling/test.png") ``` <img src="image/tb01_data-wrangling/test.png" width="1083" /> --- ## gather ```r knitr::include_graphics("image/tb01_data-wrangling/gather.png") ``` <img src="image/tb01_data-wrangling/gather.png" width="1285" /> --- ## gather ```r knitr::include_graphics("image/tb01_data-wrangling/gather2.png") ``` <img src="image/tb01_data-wrangling/gather2.png" width="1304" /> --- ## test2 ```r knitr::include_graphics("image/tb01_data-wrangling/test2.png") ``` <img src="image/tb01_data-wrangling/test2.png" width="935" /> --- ## spread ```r knitr::include_graphics("image/tb01_data-wrangling/spread.png") ``` <img src="image/tb01_data-wrangling/spread.png" width="1289" /> --- ## spread ```r knitr::include_graphics("image/tb01_data-wrangling/spread2.png") ``` <img src="image/tb01_data-wrangling/spread2.png" width="1319" /> --- ## gther & spread ```r knitr::include_graphics("image/tb01_data-wrangling/gather-spread.png") ``` <img src="image/tb01_data-wrangling/gather-spread.png" width="1187" /> --- ## separate ```r knitr::include_graphics("image/tb01_data-wrangling/separate.png") ``` <img src="image/tb01_data-wrangling/separate.png" width="1265" /> --- ## unite ```r knitr::include_graphics("image/tb01_data-wrangling/unite.png") ``` <img src="image/tb01_data-wrangling/unite.png" width="1284" /> --- ## recap ```r knitr::include_graphics("image/tb01_data-wrangling/recap1.png") ``` <img src="image/tb01_data-wrangling/recap1.png" width="1208" /> -- ## dplyr A package that helps transform tabular data. > Data sets contain more information than they display ?select ?filter ?arrange ?mutate ?summarise ?group_by