class: center, middle, inverse, title-slide # Review of the second day’s material --- layout: true <div class="my-footer"> <span> <img src="../img/au_logo_black.png" alt="Aarhus University", width="140"> </span> </div> --- class: center, middle # Version control with Git --- ## Using Git, basic workflow .pull-left[ - Version control is *really* important, but also difficult - Repository is all the files in a folder tracked by Git and saved as history in `.git/` - Files that are "tracked" will have changes recorded in history (when committed) - Commit small changes and commit often ] -- .pull-right[ 1. Start tracking new files (`git add` and `git commit`; "Stage" then "Commit") 1. Check "status" of repository (`git status`, in Git tab) 1. Add and commit modified files (`git add` and `git commit`; "Stage" then "Commit") 1. Check what was recently done to the repo (`git log`; "History" tab in Git Interface) 1. Synch with GitHub, if set up (`git push` to upload, `git pull` to download; "Push" or "Pull") ] --- class: center, middle # Data visualization with ggplot2 --- ## Final exercise: Code to create first plot .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes)) %>% ggplot(aes(y = BMI, x = Poverty, colour = Diabetes)) + geom_point(alpha = 0.4) + geom_smooth(size = 2, method = "gam") + facet_grid(cols = vars(SurveyYr), rows = vars(Gender)) + scale_color_viridis_d(end = 0.8) + theme_classic() + theme( strip.background = element_blank(), panel.background = element_rect(fill = "grey95"), axis.line = element_line(colour = "grey80") ) ``` ] .pull-left[ <!-- --> ] --- ## Final exercise: Remove NA and set base plot .pull-left[ ```r NHANES %>% * filter(!is.na(Diabetes)) %>% * ggplot(aes(y = BMI, x = Poverty, * colour = Diabetes)) + geom_point(alpha = 0.4) + geom_smooth(size = 2, method = "gam") + facet_grid(cols = vars(SurveyYr), rows = vars(Gender)) + scale_color_viridis_d(end = 0.8) + theme_classic() + theme( strip.background = element_blank(), panel.background = element_rect(fill = "grey95"), axis.line = element_line(colour = "grey80") ) ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add points and smooth geoms .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes)) %>% ggplot(aes(y = BMI, x = Poverty, colour = Diabetes)) + * geom_point(alpha = 0.4) + * geom_smooth(size = 2, method = "gam") + facet_grid(cols = vars(SurveyYr), rows = vars(Gender)) + scale_color_viridis_d(end = 0.8) + theme_classic() + theme( strip.background = element_blank(), panel.background = element_rect(fill = "grey95"), axis.line = element_line(colour = "grey80") ) ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add column by row facets .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes)) %>% ggplot(aes(y = BMI, x = Poverty, colour = Diabetes)) + geom_point(alpha = 0.4) + geom_smooth(size = 2, method = "gam") + * facet_grid(cols = vars(SurveyYr), * rows = vars(Gender)) + scale_color_viridis_d(end = 0.8) + theme_classic() + theme( strip.background = element_blank(), panel.background = element_rect(fill = "grey95"), axis.line = element_line(colour = "grey80") ) ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add colour scheme and set theme .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes)) %>% ggplot(aes(y = BMI, x = Poverty, colour = Diabetes)) + geom_point(alpha = 0.4) + geom_smooth(size = 2, method = "gam") + facet_grid(cols = vars(SurveyYr), rows = vars(Gender)) + * scale_color_viridis_d(end = 0.8) + * theme_classic() + * theme( * strip.background = element_blank(), * panel.background = * element_rect(fill = "grey95"), * axis.line = * element_line(colour = "grey80") * ) ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Code to create second plot .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes), !is.na(Education)) %>% ggplot(aes(x = Education, colour = Diabetes, y = TotChol)) + geom_boxplot(fill = "grey90", outlier.size = 0.5, size = 0.75) + facet_grid(cols = vars(Gender)) + scale_color_brewer(type = "qual") + theme_minimal() + labs(y = "Total Cholesterol") + coord_flip() ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Remove NA and set base .pull-left[ ```r NHANES %>% * filter(!is.na(Diabetes), * !is.na(Education)) %>% * ggplot(aes(x = Education, * colour = Diabetes, * y = TotChol)) + geom_boxplot(fill = "grey90", outlier.size = 0.5, size = 0.75) + facet_grid(cols = vars(Gender)) + scale_color_brewer(type = "qual") + theme_minimal() + labs(y = "Total Cholesterol") + coord_flip() ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add boxplot geom .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes), !is.na(Education)) %>% ggplot(aes(x = Education, colour = Diabetes, y = TotChol)) + * geom_boxplot(fill = "grey90", * outlier.size = 0.5, * size = 0.75) + facet_grid(cols = vars(Gender)) + scale_color_brewer(type = "qual") + theme_minimal() + labs(y = "Total Cholesterol") + coord_flip() ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add column facets .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes), !is.na(Education)) %>% ggplot(aes(x = Education, colour = Diabetes, y = TotChol)) + geom_boxplot(fill = "grey90", outlier.size = 0.5, size = 0.75) + * facet_grid(cols = vars(Gender)) + scale_color_brewer(type = "qual") + theme_minimal() + labs(y = "Total Cholesterol") + coord_flip() ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Add colour scheme and set theme .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes), !is.na(Education)) %>% ggplot(aes(x = Education, colour = Diabetes, y = TotChol)) + geom_boxplot(fill = "grey90", outlier.size = 0.5, size = 0.75) + facet_grid(cols = vars(Gender)) + * scale_color_brewer(type = "qual") + * theme_minimal() + * labs(y = "Total Cholesterol") + coord_flip() ``` ] .pull-right[ <!-- --> ] --- ## Final exercise: Flip the x and y axes .pull-left[ ```r NHANES %>% filter(!is.na(Diabetes), !is.na(Education)) %>% ggplot(aes(x = Education, colour = Diabetes, y = TotChol)) + geom_boxplot(fill = "grey90", outlier.size = 0.5, size = 0.75) + facet_grid(cols = vars(Gender)) + scale_color_brewer(type = "qual") + theme_minimal() + labs(y = "Total Cholesterol") + * coord_flip() ``` ] .pull-right[ <!-- --> ]