class: center, middle, inverse, title-slide #
gganimate - Titanic ###
Son Nguyen
--- <style> .remark-slide-content { background-color: #FFFFFF; border-top: 80px solid #F9C389; font-size: 17px; font-weight: 300; line-height: 1.5; padding: 1em 2em 1em 2em } .inverse { background-color: #696767; border-top: 80px solid #696767; text-shadow: none; background-image: url(https://github.com/goodekat/presentations/blob/master/2019-isugg-gganimate-spooky/figures/spider.png?raw=true); background-position: 50% 75%; background-size: 150px; } .your-turn{ background-color: #8C7E95; border-top: 80px solid #F9C389; text-shadow: none; background-image: url(https://github.com/goodekat/presentations/blob/master/2019-isugg-gganimate-spooky/figures/spider.png?raw=true); background-position: 95% 90%; background-size: 75px; } .title-slide { background-color: #F9C389; border-top: 80px solid #F9C389; background-image: none; } .title-slide > h1 { color: #111111; font-size: 40px; text-shadow: none; font-weight: 400; text-align: left; margin-left: 15px; padding-top: 80px; } .title-slide > h2 { margin-top: -25px; padding-bottom: -20px; color: #111111; text-shadow: none; font-weight: 300; font-size: 35px; text-align: left; margin-left: 15px; } .title-slide > h3 { color: #111111; text-shadow: none; font-weight: 300; font-size: 25px; text-align: left; margin-left: 15px; margin-bottom: -30px; } </style> <style type="text/css"> .left-code { color: #777; width: 40%; height: 92%; float: left; } .right-plot { width: 59%; float: right; padding-left: 1%; } </style> --- class: inverse, middle, center # Titanic --- # Set up Packages to load if you are following along ```r # Loads the library library(gganimate) # Other libraries that will be used library(ggplot2) library(tidyverse) library(knitr) ``` --- # Data ```r df <- read_csv('https://bryantstats.github.io/math421/data/titanic.csv') df <- df %>% mutate(Survived = as.character(Survived), Pclass = as.character(Pclass)) ``` --- # Static Plot .left-code[ ```r df %>% ggplot(aes(x = Sex, fill=Survived))+ geom_bar(position = 'fill') ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-3-1.png" style="display: block; margin: auto;" /> ] --- # Dynamic Plot .left-code[ ```r df %>% ggplot(aes(x = Sex, fill=Survived))+ geom_bar(position = 'fill')+ * transition_states(Pclass) ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-4-1.gif" style="display: block; margin: auto;" /> ] --- # Dynamic Plot .left-code[ ```r df %>% ggplot(aes(x = Sex, fill=Survived))+ geom_bar(position = 'fill')+ * transition_states(Pclass) + * labs(title = 'Class: {closest_state}') ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-5-1.gif" style="display: block; margin: auto;" /> ] --- # Static Plot .left-code[ ```r df %>% ggplot(aes(x = Fare, y = Age, color=Survived))+ geom_point() ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-6-1.png" style="display: block; margin: auto;" /> ] --- # Dynamic Plot .left-code[ ```r df %>% ggplot(aes(x = Fare, y = Age, color=Survived))+ geom_point()+ * transition_states(Sex)+ * labs(title = 'Sex: {closest_state}') ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-7-1.gif" style="display: block; margin: auto;" /> ] --- # Dynamic Plot .left-code[ ```r df %>% ggplot(aes(x = Fare, y = Age, color=Survived))+ geom_point()+ * transition_states(Pclass)+ * labs(title = 'Class: {closest_state}') ``` ] .right-plot[ <img src="8_viz_titanic_files/figure-html/unnamed-chunk-8-1.gif" style="display: block; margin: auto;" /> ]