background-image: url("img/logo_padded.001.jpeg") background-position: left background-size: 60% class: middle, center, .pull-right[ <br> ## .base_color[Graphing with] ## .base_color[`ggplot2`] <br> <br> ### .navy[Kelly McConville] #### .navy[ Stat 108 | Week 2 | Spring 2023] ] --- ## Announcements * [Office Hours Schedule](https://docs.google.com/spreadsheets/d/1HqEmr4tEtFPWRrF5TJHd1VgtVD030w6aAYySoFTnhBw/edit?usp=share_link) + Some office hours will start in Week 3 so make sure to check the schedule. * [Section Schedule](https://docs.google.com/spreadsheets/d/1DkR88j_jIkn9ZrA30FA8u3EAusAUaDN5TGhtuUVEyYA/edit?usp=share_link) * Dates for Project 1 and Project 2 now in the [Tentative Schedule](https://docs.google.com/spreadsheets/d/1Ejyq-jcg7aCEqI3W4ahx4LrISTNewV2s6u-xozOx6Zg/edit?usp=sharing) * Week 2 Lecture Quiz released at 10:30am on Wednesday. + Due at noon on Friday. * P-Set 1 released at 9am on Thursday. + Will discuss how to access the p-sets on Wednesday. + Due at 5pm the following Wednesday --- ## Week 2 Goals .pull-left[ **Mon Lecture** * Basics of `ggplot2` * Explore several `geoms`. * And a little data wrangling with `dplyr` as needed! ] .pull-right[ **Wed Lecture** * Context! + Labels + Highlighting + Useful text * Look at more `geom`s. * Explore further customizations. + Color + Themes * Learn how to ask coding questions well. ] --- class: middle ### Data Viz Considerations * We could spend all semester on data viz principles. -- * Be thoughtful and iterate. -- * Let's spend some time considering the strengths and weaknesses of the [graphs we encountered last time](https://docs.google.com/presentation/d/17cq7fA3noVyeTu-5syzY6e2Lq5rdSZo-n81hSbmrjFc/edit?usp=sharing). + You identified: + Clearest story + Most memorable + Best overall -- * Spending time with well made (though not always perfect) graphs is a good way to get ideas. Good sources: + [NYTimes: What's Going on in this Graph?]() + [https://fivethirtyeight.com/](https://fivethirtyeight.com/) + [Mona Chalabi's work](https://monachalabi.com) --- ## Our Voting Results * Disclaimer: I teach Stat 100 right after Stat 108 and I think a Stat 100 student took off with half of our graphs! + Update: Found them... <img src="stat108_wk02mon_files/figure-html/unnamed-chunk-1-1.png" width="648" style="display: block; margin: auto;" /> --- ## Recall: The Grammar of Graphics .pull-left[ * **data**: dataset that contains the data * **geom**: geometric shape that the data are mapped to + point, line, bar, text, ... * **aes**thetic: visual properties of the **geom** + x position, y position, color, fill, shape * **coord**: coordinate system + Cartesian, polar, geographic * **scale**: controls how data are mapped to the visual values of the aesthetic + EX: particular colors, linear * **guide**: legend to help user convert visual display back to the data ] .pull-right[ <img src="img/layers.png" width="100%" style="display: block; margin: auto;" /> ] --- ## ggplot2 example code ```r ggplot(data = ---, mapping = aes(---)) + geom_---(---) + coord_---() + scale_---_---() + --- ``` --- ### Example: Over the course of a year, how does the daily number of births vary? <img src="stat108_wk02mon_files/figure-html/unnamed-chunk-4-1.png" width="576" style="display: block; margin: auto;" /> -- * What patterns do you see? --- ### Example ```r # Load library that has dataset of interest library(mosaicData) # Grab data data(Births2015) # Load tidyverse (which contains ggplot2) library(tidyverse) ``` --- ### Example .pull-left[ ```r # Example code ggplot(data = ---, mapping = aes(---)) + geom_---(---) + coord_---() + scale_---_---() + --- ``` ```r # Create plot ggplot(data = Births2015, mapping = aes(x = date, y = births)) + geom_point() ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Example: Cycles related to day of the week? ```r # Look at structure of data with dplyr function glimpse(Births2015) ``` ``` ## Rows: 365 ## Columns: 8 ## $ date <date> 2015-01-01, 2015-01-02, 2015-01-03, 2015-01-04, 2015-01-… ## $ births <dbl> 8068, 10850, 8328, 7065, 11892, 12425, 12141, 12094, 1186… ## $ wday <ord> Thu, Fri, Sat, Sun, Mon, Tue, Wed, Thu, Fri, Sat, Sun, Mo… ## $ year <dbl> 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 201… ## $ month <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, … ## $ day_of_year <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17… ## $ day_of_month <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17… ## $ day_of_week <dbl> 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 1, 2, … ``` --- ### Example: Cycles related to day of the week? .pull-left[ ```r # Create plot ggplot(data = Births2015, mapping = aes(x = date, y = births, color = day_of_week)) + geom_point() ``` * Additional aesthetic: + Why is this not quite what we want? What do we want? * What happened to the aspect ratio when we added the legend? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot2-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Example: Cycles related to day of the week? .pull-left[ ```r # Create plot ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_point() + theme(legend.position = "bottom") ``` * You can also adjust the aspect ratio with the R chunk option: `fig.asp` * What if we want to see the *direction* that the number of births take over time for each day of the week? + New visual cue/`geom`? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot3-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Example .pull-left[ ```r # Create plot ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_line() + theme(legend.position = "bottom") ``` * What if we want visual cues for both **position** and **direction**? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot4-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Example .pull-left[ ```r # Create plot ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_line() + geom_point() + theme(legend.position = "bottom") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot5-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Coordinate System Layer .pull-left[ ```r library(lubridate) ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_line() + geom_point() + theme(legend.position = "bottom") + coord_cartesian(xlim = as_date(c("2015-01-01", "2015-01-31"))) ``` * How did this new layer change our plot? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot6-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Setting instead of Mapping .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = "midnightblue")) + geom_point() ``` * What if we want all the points to be colored "midnightblue"? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot7-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Setting instead of Mapping .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births)) + geom_point(color = "midnightblue") ``` * Here we'd say: + `date` is **mapped** to `x` + `births` is **mapped** to `y` + "midnightblue" **set** the `color` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot8-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Setting instead of Mapping .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births)) + geom_point(color = "#ff006e") ``` * Can also supply hex codes for colors! ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot9-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Setting instead of Mapping .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_point(color = "#ff006e") + geom_line() + theme(legend.position = "bottom") ``` * Difference between setting/mapping aesthetics in the base layer or a specific `geom` layer ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot10-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Layer order (sometimes) matters .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_line() + geom_point(color = "#ff006e") + theme(legend.position = "bottom") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot11-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Let's explore other **geom**s * Many are listed on the first page of the [`ggplot2` cheatsheet](https://raw.githubusercontent.com/rstudio/cheatsheets/main/data-visualization.pdf). * Can also ask R: ```r apropos("geom_") ``` ``` ## [1] "geom_abline" "geom_area" "geom_bar" ## [4] "geom_bin_2d" "geom_bin2d" "geom_blank" ## [7] "geom_boxplot" "geom_col" "geom_contour" ## [10] "geom_contour_filled" "geom_count" "geom_crossbar" ## [13] "geom_curve" "geom_density" "geom_density_2d" ## [16] "geom_density_2d_filled" "geom_density2d" "geom_density2d_filled" ## [19] "geom_dotplot" "geom_errorbar" "geom_errorbarh" ## [22] "geom_freqpoly" "geom_function" "geom_hex" ## [25] "geom_histogram" "geom_hline" "geom_jitter" ## [28] "geom_label" "geom_line" "geom_linerange" ## [31] "geom_map" "geom_path" "geom_point" ## [34] "geom_pointrange" "geom_polygon" "geom_qq" ## [37] "geom_qq_line" "geom_quantile" "geom_raster" ## [40] "geom_rect" "geom_ribbon" "geom_rug" ## [43] "geom_segment" "geom_sf" "geom_sf_label" ## [46] "geom_sf_text" "geom_smooth" "geom_spoke" ## [49] "geom_step" "geom_text" "geom_tile" ## [52] "geom_violin" "geom_vline" "update_geom_defaults" ``` --- ### Adding Curve(s) .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_point() + geom_smooth(method = "lm", se = FALSE) + theme(legend.position = "bottom") ``` * Does a multiple linear regression line(s) capture the trend? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot12-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Adding Curve(s) .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_point() + geom_smooth(se = FALSE) + theme(legend.position = "bottom") ``` * The default LOESS smoother usually does a reasonable job. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot13-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Adding Curve(s) .pull-left[ ```r ggplot(data = Births2015, mapping = aes(x = date, y = births, color = wday)) + geom_point() + geom_smooth(color = "black", se = FALSE) + theme(legend.position = "bottom") ``` * What happened? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/birthsPlot14-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### New Example: Movies and the Bechdel Test * Need a new dataset with more categorical variables * **The Alison Bechdel Rule**: A movie passes the test if: + There are at least two named women in the picture + They have a conversation with each other at some point + That conversation isn’t about a male character * Movies from 1970 - 2013 ```r movies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-03-09/movies.csv') %>% filter(rated %in% c("R", "PG-13", "PG", "G")) ``` --- ### New Example: Movies and the Bechdel Test ```r glimpse(movies) ``` ``` ## Rows: 1,549 ## Columns: 34 ## $ year <dbl> 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 20… ## $ imdb <chr> "tt2024544", "tt1272878", "tt0453562", "tt1335975", "tt1… ## $ title <chr> "12 Years a Slave", "2 Guns", "42", "47 Ronin", "A Good … ## $ test <chr> "notalk-disagree", "notalk", "men", "men", "notalk", "ok… ## $ clean_test <chr> "notalk", "notalk", "men", "men", "notalk", "ok", "ok", … ## $ binary <chr> "FAIL", "FAIL", "FAIL", "FAIL", "FAIL", "PASS", "PASS", … ## $ budget <dbl> 2.00e+07, 6.10e+07, 4.00e+07, 2.25e+08, 9.20e+07, 1.20e+… ## $ domgross <chr> "53107035", "75612460", "95020213", "38362475", "6734919… ## $ intgross <chr> "158607035", "132493015", "95020213", "145803842", "3042… ## $ code <chr> "2013FAIL", "2013FAIL", "2013FAIL", "2013FAIL", "2013FAI… ## $ budget_2013 <dbl> 2.00e+07, 6.10e+07, 4.00e+07, 2.25e+08, 9.20e+07, 1.20e+… ## $ domgross_2013 <chr> "53107035", "75612460", "95020213", "38362475", "6734919… ## $ intgross_2013 <chr> "158607035", "132493015", "95020213", "145803842", "3042… ## $ period_code <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… ## $ decade_code <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… ## $ imdb_id <chr> "2024544", "1272878", "0453562", "1335975", "1606378", "… ## $ plot <chr> "In the antebellum United States, Solomon Northup, a fre… ## $ rated <chr> "R", "R", "PG-13", "PG-13", "R", "R", "PG-13", "PG-13", … ## $ response <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR… ## $ language <chr> "English", "English, Spanish", "English", "English, Japa… ## $ country <chr> "USA, UK", "USA", "USA", "USA", "USA", "UK", "USA", "USA… ## $ writer <chr> "John Ridley (screenplay), Solomon Northup (based on \"T… ## $ metascore <dbl> 97, 55, 62, 29, 28, 55, 48, 33, 90, 58, 52, 78, 83, 53, … ## $ imdb_rating <dbl> 8.3, 6.8, 7.6, 6.6, 5.4, 7.8, 5.7, 5.0, 7.5, 7.4, 6.2, 7… ## $ director <chr> "Steve McQueen", "Baltasar Kormákur", "Brian Helgeland",… ## $ released <chr> "08 Nov 2013", "02 Aug 2013", "12 Apr 2013", "25 Dec 201… ## $ actors <chr> "Chiwetel Ejiofor, Dwight Henry, Dickie Gravois, Bryan B… ## $ genre <chr> "Biography, Drama, History", "Action, Comedy, Crime", "B… ## $ awards <chr> "Won 3 Oscars. Another 131 wins & 137 nominations.", "1 … ## $ runtime <chr> "134 min", "109 min", "128 min", "118 min", "98 min", "1… ## $ type <chr> "movie", "movie", "movie", "movie", "movie", "movie", "m… ## $ poster <chr> "http://ia.media-imdb.com/images/M/MV5BMjExMTEzODkyN15BM… ## $ imdb_votes <dbl> 143446, 87301, 43608, 25735, 123837, 85871, 18973, 10826… ## $ error <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, … ``` --- class: middle, center ## What are useful `geom`s for describing amounts/frequencies? --- ### Amounts: `geom_bar` .pull-left[ ```r ggplot(data = movies, mapping = aes(x = binary)) + geom_bar() ``` * Verbalize the mapping of **data** to **geom_bar()**. + How is this mapping different from **geom_point()**? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies1-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Another option: `geom_col` .pull-left[ ```r # First wrangle with dplyr movies_ag <- count(movies, binary) movies_ag ``` ``` ## # A tibble: 2 × 2 ## binary n ## <chr> <int> ## 1 FAIL 863 ## 2 PASS 686 ``` ```r ggplot(data = movies_ag, mapping = aes(x = binary, y = n)) + geom_col() ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies2-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### `geom_point` again .pull-left[ ```r ggplot(data = movies_ag, mapping = aes(x = binary, y = n)) + geom_point(size = 4) ``` * If you are worried about the data-ink ratio... ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies3-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### `geom_point` + `geom_segment` .pull-left[ ```r ggplot(data = movies_ag, mapping = aes(x = binary, y = n)) + geom_segment(mapping = aes(xend = binary), yend = 0) + geom_point(size = 10, color = "orange") + ylim(c(0, 875)) ``` * Lollipop chart: compromise? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies4-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Two categorical variables: `geom_bar` .pull-left[ ```r ggplot(data = movies, mapping = aes(x = rated, fill = binary)) + geom_bar() ``` * Describe the mapping. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies5-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Two categorical variables: `geom_bar` .pull-left[ ```r ggplot(data = movies, mapping = aes(x = rated, fill = binary)) + geom_bar(position = "fill") ``` * Describe the mapping. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies6-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Two categorical variables: `geom_bar` .pull-left[ ```r ggplot(data = movies, mapping = aes(x = rated, fill = binary)) + geom_bar(position = "dodge") ``` * Describe the mapping. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies6b-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Two categorical variables: `geom_tile` .pull-left[ ```r movies_ag <- count(movies, rated, binary) ggplot(data = movies_ag, mapping = aes(x = rated, y = binary, fill = n)) + geom_tile() ``` * Describe the mapping. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies7-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Two categorical variables: `geom_tile` .pull-left[ ```r movies_ag <- count(movies, rated, binary) ggplot(data = movies_ag, mapping = aes(x = rated, y = binary, fill = n)) + geom_tile() + scale_fill_viridis_c(direction = -1) ``` * Change the `fill` scale! ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies8-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Can display more than frequencies! .pull-left[ ```r movies_ag <- group_by(movies, rated, binary) %>% summarize(mean_budget = mean(budget)) ggplot(data = movies_ag, mapping = aes(x = rated, y = binary, fill = mean_budget)) + geom_tile() + scale_fill_viridis_c(direction = -1) + theme(legend.position = "bottom") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies9-1.png" width="768" style="display: block; margin: auto;" /> ] --- class: middle, center ## What are useful `geom`s (graphs) for visualizing distributions? --- ### Distributions: `geom_histogram` .pull-left[ ```r ggplot(movies, aes(x = budget)) + geom_histogram() ``` * Verbalize the mapping. ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies10-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_histogram` .pull-left[ ```r ggplot(movies, aes(x = budget)) + geom_histogram(bins = 50, color = "white", fill = "darkcyan") ``` * Can modify the mapping via the `binwidth` or `bins` arguments ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies11-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_histogram` .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_histogram(bins = 50, color = "white") ``` * What is problematic about this graph? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies12-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_histogram` .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_histogram(bins = 50, alpha = 0.4, position = "identity") ``` * Still problematic ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies13-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### One option: Facetting .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_histogram(bins = 50) + facet_wrap(~binary) + guides(fill = "none") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies14-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### One option: Facetting .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_histogram() + facet_grid(rated ~ binary, scales = "free_y") + guides(fill = "none") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies14b-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Another option: `geom_density` .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_density(alpha = 0.4) + theme(legend.position = "bottom") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies15-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_density` .pull-left[ ```r ggplot(movies, aes(x = budget, fill = binary)) + geom_density(position = "fill") + theme(legend.position = "bottom") ``` * How did the mapping change? What does this add to the story? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies16-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_boxplot` .pull-left[ ```r ggplot(movies, aes(x = binary, y = budget)) + geom_boxplot() ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies17-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_boxplot` .pull-left[ ```r ggplot(movies, aes(x = binary, y = budget)) + geom_boxplot(varwidth = TRUE, notch = TRUE) ``` * What does `varwidth` do? * Why might we add `notch = TRUE`? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies18-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_boxplot` .pull-left[ ```r ggplot(movies, aes(x = binary, y = budget, fill = rated)) + geom_boxplot() ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies19-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_violin` .pull-left[ ```r ggplot(movies, aes(x = binary, y = budget)) + geom_violin() ``` * Utility of the violin over the box? ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies20-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Distributions: `geom_violin` .pull-left[ ```r ggplot(movies, aes(x = binary, y = budget)) + geom_violin() + geom_jitter(alpha = .1, width = .1, color = "darkcyan") ``` ] .pull-right[ <img src="stat108_wk02mon_files/figure-html/movies21-1.png" width="768" style="display: block; margin: auto;" /> ] --- ### Reminders * [Office Hours Schedule](https://docs.google.com/spreadsheets/d/1HqEmr4tEtFPWRrF5TJHd1VgtVD030w6aAYySoFTnhBw/edit?usp=share_link) + Some office hours will start in Week 3 so make sure to check the schedule. * [Section Schedule](https://docs.google.com/spreadsheets/d/1DkR88j_jIkn9ZrA30FA8u3EAusAUaDN5TGhtuUVEyYA/edit?usp=share_link) * Dates for Project 1 and Project 2 now in the [Tentative Schedule](https://docs.google.com/spreadsheets/d/1Ejyq-jcg7aCEqI3W4ahx4LrISTNewV2s6u-xozOx6Zg/edit?usp=sharing) * Week 2 Lecture Quiz released at 10:30am on Wednesday. + Due at noon on Friday. * P-Set 1 released at 9am on Thursday. + Will discuss how to access the p-sets on Wednesday. + Due at 5pm the following Wednesday