layout: true <!-- this adds the link footer to all slides, depends on footer-small class in css--> <div class="footer-small"><span>https://github.com/mjfrigaard/talks/tree/main/odsc-eda-2022-04</span></div> --- name: title-slide class: title-slide, center, middle, inverse # ODSC: Data Visualization with ggplot2 #.fancy[Part 2: Creating graphs with ggplot2] ### https://bit.ly/odsc-ggplot2 <br> .large[by Martin Frigaard & Peter Spangler] Written: February 08 2022 Updated: July 23 2022 --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # Resources <br> .leftcol[ ## Links: ### - [Conference Website](https://odsc.com/boston/) ### - [Website](https://mjfrigaard.github.io/odsc-ggplot2-2022/) ### - [Part 1](https://mjfrigaard.github.io/odsc-ggplot2-2022/eda-slides-01.html#1) ### - [Part 2](https://mjfrigaard.github.io/odsc-ggplot2-2022/eda-slides-02.html#1) ] .rightcol[ ## Materials: ### - [RStudio.Cloud](https://rstudio.cloud/project/3941178) ### - [Github Repo](https://github.com/mjfrigaard/odsc-ggplot2-2022/tree/gh-pages) ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% ## Outline .leftcol[ ### Part 1 .font70[ **Exploratory data analysis** - *What is it, who does it, and why it's important* **A Bayesian mindset** - *Priors -> new information -> posteriors* **The grammar of graphics** - *Layers, aesthetics, and geoms* ] ] -- .rightcol[ ### .red[Part 2] .font70[ **Build labels first** - *Set expectations* **Exercises & solutions** - *RStudio.Cloud* **Creating graphs** - *Building graphs layer-by-layer, global vs. local mapping, visual encodings* **Applying the grammar** - *Mapping vs. setting aesthetics, combining layers, facets* ] ] --- class: center, middle, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # .fancy[.large[PART 2]] -- #### .left[*Tip: writing code can be frustrating, especially in the beginning...*] -- #### .center[*...it doesn't always produce a tangible result...*] -- #### .right[*...but creating visualizations is rewarding!!!*] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # `ggplot2`: before we start <br> ### **Build the labels first!** ### - Create a title, subtitle (with data source), and x/y axis labels -- .leftcol60[.code60[ ```r labs_pengiuns <- ggplot2::labs( title = "Flipper vs. Bill Length", subtitle = "source: palmerpenguins::penguins", x = "flipper length (mm)", y = "bill length (mm)") ``` ]] -- .rightcol40[ .center[.large[.red[<- our expectations]]] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # `ggplot2`: build graph, check labels .leftcol40[.code50[ ```r labs_pengiuns <- ggplot2::labs( title = "Flipper vs. Bill Length", subtitle = "source: palmerpenguins::penguins", x = "flipper length (mm)", y = "bill length (mm)") ggplot(data = penguins, mapping = aes(x = bill_length_mm, y = flipper_length_mm) ) + * labs_pengiuns ``` ]] -- .rightcol60[ <img src="images/plot-penguins-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ### .red[What's wrong here?] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% ## `ggplot2`: build graph, check labels, .red[revise] -- .leftcol40[.code50[ ```r labs_pengiuns <- ggplot2::labs( title = "Flipper vs. Bill Length", subtitle = "source: palmerpenguins::penguins", * x = "flipper length (mm)", * y = "bill length (mm)") ggplot(data = penguins, * mapping = aes(x = flipper_length_mm, * y = bill_length_mm) ) + labs_pengiuns ``` ]] -- .rightcol60[ <img src="images/plot-penguins-revise-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ## .green[FIXED!!!] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% ## `ggplot2`: build graph, check labels, .red[REVISE] > .blue[*Revision Sharpens Thinking: More particularly, rewriting is the key to improved thinking.*] -- > .blue[*It demands a real open-mindedness and objectivity. It demands a willingness to cull verbiage so that ideas stand out clearly. And it demands a willingness to meet logical contradictions head on and trace them to the premises that have created them.*] -- > .red[*In short, it forces a writer to get up his courage and expose his thinking process to his own intelligence.* — Marvin H. Swift, HBR [Clear Writing Means Clear Thinking Means…](https://hbr.org/1973/01/clear-writing-means-clear-thinking-means)] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Exercises & Solutions]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Set up .cols3[ ### In your RStudio.Cloud, you will see the following: ] .cols3[ <img src="images/rscloud-landing.png" width="80%" height="80%" style="display: block; margin: auto;" /> ] .cols3[ ### Log in with your .red[GitHub] credentials ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Set up ### On the top of the RStudio IDE, you will see the following: <br> <img src="images/rscloud-env.png" width="80%" height="80%" style="display: block; margin: auto;" /> <br> ### Click on .red[Save a Permanent Copy] to add this project to your workspace --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Set up ### In the .blue[Files] pane, click on the `inst.R` file to open it <img src="images/rscloud-open-inst.png" width="80%" height="80%" style="display: block; margin: auto;" /> --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Set up ### In the .blue[Source] pane, click on the *Source* icon to run `inst.R` <img src="images/rscloud-source-inst.png" width="60%" height="60%" style="display: block; margin: auto;" /> ### This sends the code in the .blue[Source] pane to the .blue[Console] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Exercises ### The exercises are in the `graphs/` folder <img src="images/graphs-files.png" width="80%" height="80%" style="display: block; margin: auto;" /> --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # RStudio.Cloud: Solutions ### Each exercise has a solution file in `solutions/` folder <img src="images/sols-files.png" width="80%" height="80%" style="display: block; margin: auto;" /> --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # The data ### We're going to use the `palmerpenguins::penguins` ### - Below are three options for viewing a dataset in RStudio: -- .cols3[.code90[ ```r View(penguins) ``` ]] -- .cols3[.code90[ ```r glimpse(penguins) ``` ]] -- .cols3[.code90[ ```r str(penguins) ``` ]] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Viewing data ### `View()` opens the RStudio data viewer <img src="images/penguins-View.png" width="80%" height="80%" style="display: block; margin: auto;" /> --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Viewing data ### `glimpse()` and `str()` are displayed in the console .leftcol[ <img src="images/penguins-glimpse.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] .rightcol[ <img src="images/penguins-str.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Build from scratch, layer-by-layer]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 01] Step 0 = LABELS! We want to build the labels **first**: - title = "Bill and flipper length of Palmer penguins" - subtitle = "Size measurements for adult foraging penguins" - x = "Bill length (mm)" - y = "Flipper length (mm)" ```r # build labels labs_bill_vs_flippper <- ggplot2::labs( title = "Bill and flipper length of Palmer penguins", subtitle = "Size measurements for adult foraging penguins", x = "Bill length (mm)", y = "Flipper length (mm)") ``` --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 01] Step 1: Initialize plot with data .leftcol[ .small[The `ggplot2::ggplot()` function initiates the plot] .code60[ ```r ggplot(data = ) ``` ] .small[Place `penguins` in the data argument] .code60[ ```r *ggplot(data = penguins) ``` ] ] -- .rightcol[ .small[This gives us a blank canvas!] .code60[ <img src="images/g01-initialize-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 02] Step 2: Map variables to positions We have our data and labels--we just need to add our variables .leftcol[ .small[Map `bill_length_mm` to `x`] .code60[ ```r ggplot(data = penguins, * mapping = aes(x = bill_length_mm, )) ``` ] .small[Map `flipper_length_mm` to `y`] .code60[ ```r ggplot(data = penguins, * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) ``` ] ] -- .rightcol[ .small[Now our canvas has `x` and `y` axes] <img src="images/g02-position-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] -- <br><br><br> Now we have our variables on our graph! --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 03] Step 3: Adding geoms .leftcol[ .small[Add the `geom_point()` function with the `+` symbol] .code60[ ```r ggplot(data = penguins, mapping = aes(x = bill_length_mm, y = flipper_length_mm)) + * geom_point() ``` ] ] -- .rightcol[ .small[The `geom_point()` function tells R we want to see the points (or dots) on our canvas] <img src="images/g03-geom-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 04] Step 4: Don't forget the labels! .leftcol[ .small[Finally, we want to add the labels we created (`labs_bill_vs_flippper`)] .code60[ ```r ggplot(data = penguins, mapping = aes(x = bill_length_mm, y = flipper_length_mm)) + geom_point() + * labs_bill_vs_flippper ``` ] ] -- .rightcol[ .small[And we have our first graph!] <img src="images/g04-labels-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Global vs. local mapping]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Global vs. local mapping We've just created a graph by setting .green[global] aesthetics .green[Global] means aesthetic mappings are set when the graph is initialized with the `ggplot()` function -- .leftcol[ .code60[ ```r ggplot(data = penguins, * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) + geom_point() + labs_bill_vs_flippper ``` ] .small[If we map aesthetics `ggplot()`, all the following `geom_*()` layers will inherit these aesthetics.] ] -- .rightcol[ .small[Recall what goes into each layer from Part 1] <img src="images/layer-breakdown-01.png" width="52%" height="52%" style="display: block; margin: auto 0 auto auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Global vs. local mapping Mapping aesthetics .green[globally] and then adding the `geom_*()` function results in the same graph as when we map aesthetics .green[locally] (*inside* the `geom_*()` function) .leftcol[ .code40[ ```r ggplot(data = penguins, * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) + * geom_point() + labs_bill_vs_flippper ``` <img src="images/g05-global-out-1.png" width="85%" height="85%" style="display: block; margin: auto 0 auto auto;" /> ]] -- .rightcol[ .code40[ ```r ggplot(data = penguins) + * geom_point( * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) + labs_bill_vs_flippper ``` <img src="images/g05-local-out-1.png" width="85%" height="85%" style="display: block; margin: auto auto auto 0;" /> ] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Our `ggplot2` templates The template from part 1 uses .green[local] mappings (i.e. aesthetic mappings are set *inside* the `geom_*` function). -- ```r # Recall our template from Part 1 ggplot(data = <DATA>) + geom_*(mapping = aes(<AESTHETIC MAPPINGS>)) ``` -- We could adjust this template to include .green[global] mappings (and the option to include aesthetic mappings .green[locally]) ```r # Adjusted template ggplot(data = <DATA>, * mapping = aes(<AESTHETIC MAPPINGS>)) + # global mappings * geom_*(mapping = aes(<AESTHETIC MAPPINGS>)) # local mappings ``` .small[Read more [here](https://ggplot2-book.org/collective-geoms.html#different-groups-on-different-layers).] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 05] Convert .green[global] to .green[local] mappings For .red[graph 05.R], convert the global aesthetics to local aesthetics inside the `geom_point()` function .leftcol[ Global .code80[ ```r ggplot(data = penguins, * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) + geom_point() + labs_bill_vs_flippper ``` ] ] -- .rightcol[ Local .code80[ ```r ggplot(data = penguins) + geom_point( * mapping = aes(x = bill_length_mm, * y = flipper_length_mm)) + labs_bill_vs_flippper ``` ] ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Visual encodings]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # What are visual encodings? -- ### Visual encodings are what we see on the graph -- ### Things like position, size, shape, color, etc. -- ### Ranked by accuracy ("generally speaking"): <img src="images/visual-encodings.png" width="90%" height="90%" style="display: block; margin: auto;" /> --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 06] Adding color (global) Map `color` to the `species` variable in the scatter plot using .green[global] aesthetic mapping -- .leftcol[ .code60[ ```r ggplot(data = penguins, mapping = * aes(x = bill_length_mm, * y = flipper_length_mm, * color = species)) + geom_point() + labs_bill_vs_flippper ``` ] ] -- .rightcol[ <img src="images/g06-color-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 07] Adding color (local) Map `color` to the `species` variable in the scatter plot using .green[local] aesthetic mapping .leftcol[ .code60[ ```r ggplot(data = penguins, mapping = aes(x = bill_length_mm, y = flipper_length_mm)) + * geom_point(aes(color = species)) + labs_bill_vs_flippper ``` ] ] -- .rightcol[ <img src="images/g07-color-local-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> .small[The `x` and `y` aesthetics are inherited from the `ggplot()` function, but the `color` aesthetic comes from the `geom_point()` layer] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 08] Color vs. Fill Below we'll look at the counts of `sex` vs. `species` of Palmer penguins -- .leftcol[ .small[Create labels] .code60[ ```r labs_sex_vs_species <- ggplot2::labs( title = "Sex by species of Palmer penguins", subtitle = "Counts for adult foraging penguins", x = "Sex", fill = "Species") ``` .small[Create `penguins_no_miss` by removing missing values] ```r penguins_no_miss <- drop_na(data = penguins) ``` ] ] -- .rightcol[ .code60[ ```r penguins_no_miss ``` .small[ <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["species"],"name":[1],"type":["fct"],"align":["left"]},{"label":["island"],"name":[2],"type":["fct"],"align":["left"]},{"label":["bill_length_mm"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["bill_depth_mm"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["flipper_length_mm"],"name":[5],"type":["int"],"align":["right"]},{"label":["body_mass_g"],"name":[6],"type":["int"],"align":["right"]},{"label":["sex"],"name":[7],"type":["fct"],"align":["left"]},{"label":["year"],"name":[8],"type":["int"],"align":["right"]}],"data":[{"1":"Adelie","2":"Torgersen","3":"39.1","4":"18.7","5":"181","6":"3750","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"39.5","4":"17.4","5":"186","6":"3800","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"40.3","4":"18.0","5":"195","6":"3250","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"36.7","4":"19.3","5":"193","6":"3450","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"39.3","4":"20.6","5":"190","6":"3650","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"38.9","4":"17.8","5":"181","6":"3625","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"39.2","4":"19.6","5":"195","6":"4675","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"41.1","4":"17.6","5":"182","6":"3200","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"38.6","4":"21.2","5":"191","6":"3800","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"34.6","4":"21.1","5":"198","6":"4400","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"36.6","4":"17.8","5":"185","6":"3700","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"38.7","4":"19.0","5":"195","6":"3450","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"42.5","4":"20.7","5":"197","6":"4500","7":"male","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"34.4","4":"18.4","5":"184","6":"3325","7":"female","8":"2007"},{"1":"Adelie","2":"Torgersen","3":"46.0","4":"21.5","5":"194","6":"4200","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"37.8","4":"18.3","5":"174","6":"3400","7":"female","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"37.7","4":"18.7","5":"180","6":"3600","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"35.9","4":"19.2","5":"189","6":"3800","7":"female","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"38.2","4":"18.1","5":"185","6":"3950","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"38.8","4":"17.2","5":"180","6":"3800","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"35.3","4":"18.9","5":"187","6":"3800","7":"female","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"40.6","4":"18.6","5":"183","6":"3550","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"40.5","4":"17.9","5":"187","6":"3200","7":"female","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"37.9","4":"18.6","5":"172","6":"3150","7":"female","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"40.5","4":"18.9","5":"180","6":"3950","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"39.5","4":"16.7","5":"178","6":"3250","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"37.2","4":"18.1","5":"178","6":"3900","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"39.5","4":"17.8","5":"188","6":"3300","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"40.9","4":"18.9","5":"184","6":"3900","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"36.4","4":"17.0","5":"195","6":"3325","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"39.2","4":"21.1","5":"196","6":"4150","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"38.8","4":"20.0","5":"190","6":"3950","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"42.2","4":"18.5","5":"180","6":"3550","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"37.6","4":"19.3","5":"181","6":"3300","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"39.8","4":"19.1","5":"184","6":"4650","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"36.5","4":"18.0","5":"182","6":"3150","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"40.8","4":"18.4","5":"195","6":"3900","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"36.0","4":"18.5","5":"186","6":"3100","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"44.1","4":"19.7","5":"196","6":"4400","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"37.0","4":"16.9","5":"185","6":"3000","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"39.6","4":"18.8","5":"190","6":"4600","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"41.1","4":"19.0","5":"182","6":"3425","7":"male","8":"2007"},{"1":"Adelie","2":"Dream","3":"36.0","4":"17.9","5":"190","6":"3450","7":"female","8":"2007"},{"1":"Adelie","2":"Dream","3":"42.3","4":"21.2","5":"191","6":"4150","7":"male","8":"2007"},{"1":"Adelie","2":"Biscoe","3":"39.6","4":"17.7","5":"186","6":"3500","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"40.1","4":"18.9","5":"188","6":"4300","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"35.0","4":"17.9","5":"190","6":"3450","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"42.0","4":"19.5","5":"200","6":"4050","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"34.5","4":"18.1","5":"187","6":"2900","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"41.4","4":"18.6","5":"191","6":"3700","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"39.0","4":"17.5","5":"186","6":"3550","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"40.6","4":"18.8","5":"193","6":"3800","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"36.5","4":"16.6","5":"181","6":"2850","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"37.6","4":"19.1","5":"194","6":"3750","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"35.7","4":"16.9","5":"185","6":"3150","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"41.3","4":"21.1","5":"195","6":"4400","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"37.6","4":"17.0","5":"185","6":"3600","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"41.1","4":"18.2","5":"192","6":"4050","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"36.4","4":"17.1","5":"184","6":"2850","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"41.6","4":"18.0","5":"192","6":"3950","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"35.5","4":"16.2","5":"195","6":"3350","7":"female","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"41.1","4":"19.1","5":"188","6":"4100","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"35.9","4":"16.6","5":"190","6":"3050","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"41.8","4":"19.4","5":"198","6":"4450","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"33.5","4":"19.0","5":"190","6":"3600","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"39.7","4":"18.4","5":"190","6":"3900","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"39.6","4":"17.2","5":"196","6":"3550","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"45.8","4":"18.9","5":"197","6":"4150","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"35.5","4":"17.5","5":"190","6":"3700","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"42.8","4":"18.5","5":"195","6":"4250","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"40.9","4":"16.8","5":"191","6":"3700","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"37.2","4":"19.4","5":"184","6":"3900","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"36.2","4":"16.1","5":"187","6":"3550","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"42.1","4":"19.1","5":"195","6":"4000","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"34.6","4":"17.2","5":"189","6":"3200","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"42.9","4":"17.6","5":"196","6":"4700","7":"male","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"36.7","4":"18.8","5":"187","6":"3800","7":"female","8":"2008"},{"1":"Adelie","2":"Torgersen","3":"35.1","4":"19.4","5":"193","6":"4200","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"37.3","4":"17.8","5":"191","6":"3350","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"41.3","4":"20.3","5":"194","6":"3550","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"36.3","4":"19.5","5":"190","6":"3800","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"36.9","4":"18.6","5":"189","6":"3500","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"38.3","4":"19.2","5":"189","6":"3950","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"38.9","4":"18.8","5":"190","6":"3600","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"35.7","4":"18.0","5":"202","6":"3550","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"41.1","4":"18.1","5":"205","6":"4300","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"34.0","4":"17.1","5":"185","6":"3400","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"39.6","4":"18.1","5":"186","6":"4450","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"36.2","4":"17.3","5":"187","6":"3300","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"40.8","4":"18.9","5":"208","6":"4300","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"38.1","4":"18.6","5":"190","6":"3700","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"40.3","4":"18.5","5":"196","6":"4350","7":"male","8":"2008"},{"1":"Adelie","2":"Dream","3":"33.1","4":"16.1","5":"178","6":"2900","7":"female","8":"2008"},{"1":"Adelie","2":"Dream","3":"43.2","4":"18.5","5":"192","6":"4100","7":"male","8":"2008"},{"1":"Adelie","2":"Biscoe","3":"35.0","4":"17.9","5":"192","6":"3725","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"41.0","4":"20.0","5":"203","6":"4725","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"37.7","4":"16.0","5":"183","6":"3075","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"37.8","4":"20.0","5":"190","6":"4250","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"37.9","4":"18.6","5":"193","6":"2925","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"39.7","4":"18.9","5":"184","6":"3550","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"38.6","4":"17.2","5":"199","6":"3750","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"38.2","4":"20.0","5":"190","6":"3900","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"38.1","4":"17.0","5":"181","6":"3175","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"43.2","4":"19.0","5":"197","6":"4775","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"38.1","4":"16.5","5":"198","6":"3825","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"45.6","4":"20.3","5":"191","6":"4600","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"39.7","4":"17.7","5":"193","6":"3200","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"42.2","4":"19.5","5":"197","6":"4275","7":"male","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"39.6","4":"20.7","5":"191","6":"3900","7":"female","8":"2009"},{"1":"Adelie","2":"Biscoe","3":"42.7","4":"18.3","5":"196","6":"4075","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"38.6","4":"17.0","5":"188","6":"2900","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"37.3","4":"20.5","5":"199","6":"3775","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"35.7","4":"17.0","5":"189","6":"3350","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"41.1","4":"18.6","5":"189","6":"3325","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"36.2","4":"17.2","5":"187","6":"3150","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"37.7","4":"19.8","5":"198","6":"3500","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"40.2","4":"17.0","5":"176","6":"3450","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"41.4","4":"18.5","5":"202","6":"3875","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"35.2","4":"15.9","5":"186","6":"3050","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"40.6","4":"19.0","5":"199","6":"4000","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"38.8","4":"17.6","5":"191","6":"3275","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"41.5","4":"18.3","5":"195","6":"4300","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"39.0","4":"17.1","5":"191","6":"3050","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"44.1","4":"18.0","5":"210","6":"4000","7":"male","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"38.5","4":"17.9","5":"190","6":"3325","7":"female","8":"2009"},{"1":"Adelie","2":"Torgersen","3":"43.1","4":"19.2","5":"197","6":"3500","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"36.8","4":"18.5","5":"193","6":"3500","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"37.5","4":"18.5","5":"199","6":"4475","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"38.1","4":"17.6","5":"187","6":"3425","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"41.1","4":"17.5","5":"190","6":"3900","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"35.6","4":"17.5","5":"191","6":"3175","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"40.2","4":"20.1","5":"200","6":"3975","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"37.0","4":"16.5","5":"185","6":"3400","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"39.7","4":"17.9","5":"193","6":"4250","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"40.2","4":"17.1","5":"193","6":"3400","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"40.6","4":"17.2","5":"187","6":"3475","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"32.1","4":"15.5","5":"188","6":"3050","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"40.7","4":"17.0","5":"190","6":"3725","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"37.3","4":"16.8","5":"192","6":"3000","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"39.0","4":"18.7","5":"185","6":"3650","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"39.2","4":"18.6","5":"190","6":"4250","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"36.6","4":"18.4","5":"184","6":"3475","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"36.0","4":"17.8","5":"195","6":"3450","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"37.8","4":"18.1","5":"193","6":"3750","7":"male","8":"2009"},{"1":"Adelie","2":"Dream","3":"36.0","4":"17.1","5":"187","6":"3700","7":"female","8":"2009"},{"1":"Adelie","2":"Dream","3":"41.5","4":"18.5","5":"201","6":"4000","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"46.1","4":"13.2","5":"211","6":"4500","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"50.0","4":"16.3","5":"230","6":"5700","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"48.7","4":"14.1","5":"210","6":"4450","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"50.0","4":"15.2","5":"218","6":"5700","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"47.6","4":"14.5","5":"215","6":"5400","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.5","4":"13.5","5":"210","6":"4550","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"45.4","4":"14.6","5":"211","6":"4800","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.7","4":"15.3","5":"219","6":"5200","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"43.3","4":"13.4","5":"209","6":"4400","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.8","4":"15.4","5":"215","6":"5150","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"40.9","4":"13.7","5":"214","6":"4650","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"49.0","4":"16.1","5":"216","6":"5550","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"45.5","4":"13.7","5":"214","6":"4650","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"48.4","4":"14.6","5":"213","6":"5850","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"45.8","4":"14.6","5":"210","6":"4200","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"49.3","4":"15.7","5":"217","6":"5850","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"42.0","4":"13.5","5":"210","6":"4150","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"49.2","4":"15.2","5":"221","6":"6300","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.2","4":"14.5","5":"209","6":"4800","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"48.7","4":"15.1","5":"222","6":"5350","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"50.2","4":"14.3","5":"218","6":"5700","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"45.1","4":"14.5","5":"215","6":"5000","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.5","4":"14.5","5":"213","6":"4400","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.3","4":"15.8","5":"215","6":"5050","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"42.9","4":"13.1","5":"215","6":"5000","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"46.1","4":"15.1","5":"215","6":"5100","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"47.8","4":"15.0","5":"215","6":"5650","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"48.2","4":"14.3","5":"210","6":"4600","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"50.0","4":"15.3","5":"220","6":"5550","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"47.3","4":"15.3","5":"222","6":"5250","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"42.8","4":"14.2","5":"209","6":"4700","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"45.1","4":"14.5","5":"207","6":"5050","7":"female","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"59.6","4":"17.0","5":"230","6":"6050","7":"male","8":"2007"},{"1":"Gentoo","2":"Biscoe","3":"49.1","4":"14.8","5":"220","6":"5150","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"48.4","4":"16.3","5":"220","6":"5400","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"42.6","4":"13.7","5":"213","6":"4950","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"44.4","4":"17.3","5":"219","6":"5250","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"44.0","4":"13.6","5":"208","6":"4350","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"48.7","4":"15.7","5":"208","6":"5350","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"42.7","4":"13.7","5":"208","6":"3950","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"49.6","4":"16.0","5":"225","6":"5700","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.3","4":"13.7","5":"210","6":"4300","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"49.6","4":"15.0","5":"216","6":"4750","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"50.5","4":"15.9","5":"222","6":"5550","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"43.6","4":"13.9","5":"217","6":"4900","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.5","4":"13.9","5":"210","6":"4200","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"50.5","4":"15.9","5":"225","6":"5400","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"44.9","4":"13.3","5":"213","6":"5100","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.2","4":"15.8","5":"215","6":"5300","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.6","4":"14.2","5":"210","6":"4850","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"48.5","4":"14.1","5":"220","6":"5300","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.1","4":"14.4","5":"210","6":"4400","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"50.1","4":"15.0","5":"225","6":"5000","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.5","4":"14.4","5":"217","6":"4900","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.0","4":"15.4","5":"220","6":"5050","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"43.8","4":"13.9","5":"208","6":"4300","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.5","4":"15.0","5":"220","6":"5000","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"43.2","4":"14.5","5":"208","6":"4450","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"50.4","4":"15.3","5":"224","6":"5550","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.3","4":"13.8","5":"208","6":"4200","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.2","4":"14.9","5":"221","6":"5300","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.7","4":"13.9","5":"214","6":"4400","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"54.3","4":"15.7","5":"231","6":"5650","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.8","4":"14.2","5":"219","6":"4700","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"49.8","4":"16.8","5":"230","6":"5700","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"49.5","4":"16.2","5":"229","6":"5800","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"43.5","4":"14.2","5":"220","6":"4700","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"50.7","4":"15.0","5":"223","6":"5550","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"47.7","4":"15.0","5":"216","6":"4750","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.4","4":"15.6","5":"221","6":"5000","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"48.2","4":"15.6","5":"221","6":"5100","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.5","4":"14.8","5":"217","6":"5200","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"46.4","4":"15.0","5":"216","6":"4700","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"48.6","4":"16.0","5":"230","6":"5800","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"47.5","4":"14.2","5":"209","6":"4600","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"51.1","4":"16.3","5":"220","6":"6000","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.2","4":"13.8","5":"215","6":"4750","7":"female","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"45.2","4":"16.4","5":"223","6":"5950","7":"male","8":"2008"},{"1":"Gentoo","2":"Biscoe","3":"49.1","4":"14.5","5":"212","6":"4625","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"52.5","4":"15.6","5":"221","6":"5450","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"47.4","4":"14.6","5":"212","6":"4725","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"50.0","4":"15.9","5":"224","6":"5350","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"44.9","4":"13.8","5":"212","6":"4750","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"50.8","4":"17.3","5":"228","6":"5600","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"43.4","4":"14.4","5":"218","6":"4600","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"51.3","4":"14.2","5":"218","6":"5300","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"47.5","4":"14.0","5":"212","6":"4875","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"52.1","4":"17.0","5":"230","6":"5550","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"47.5","4":"15.0","5":"218","6":"4950","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"52.2","4":"17.1","5":"228","6":"5400","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"45.5","4":"14.5","5":"212","6":"4750","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"49.5","4":"16.1","5":"224","6":"5650","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"44.5","4":"14.7","5":"214","6":"4850","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"50.8","4":"15.7","5":"226","6":"5200","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"49.4","4":"15.8","5":"216","6":"4925","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"46.9","4":"14.6","5":"222","6":"4875","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"48.4","4":"14.4","5":"203","6":"4625","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"51.1","4":"16.5","5":"225","6":"5250","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"48.5","4":"15.0","5":"219","6":"4850","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"55.9","4":"17.0","5":"228","6":"5600","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"47.2","4":"15.5","5":"215","6":"4975","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"49.1","4":"15.0","5":"228","6":"5500","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"46.8","4":"16.1","5":"215","6":"5500","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"41.7","4":"14.7","5":"210","6":"4700","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"53.4","4":"15.8","5":"219","6":"5500","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"43.3","4":"14.0","5":"208","6":"4575","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"48.1","4":"15.1","5":"209","6":"5500","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"50.5","4":"15.2","5":"216","6":"5000","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"49.8","4":"15.9","5":"229","6":"5950","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"43.5","4":"15.2","5":"213","6":"4650","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"51.5","4":"16.3","5":"230","6":"5500","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"46.2","4":"14.1","5":"217","6":"4375","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"55.1","4":"16.0","5":"230","6":"5850","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"48.8","4":"16.2","5":"222","6":"6000","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"47.2","4":"13.7","5":"214","6":"4925","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"46.8","4":"14.3","5":"215","6":"4850","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"50.4","4":"15.7","5":"222","6":"5750","7":"male","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"45.2","4":"14.8","5":"212","6":"5200","7":"female","8":"2009"},{"1":"Gentoo","2":"Biscoe","3":"49.9","4":"16.1","5":"213","6":"5400","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"46.5","4":"17.9","5":"192","6":"3500","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"50.0","4":"19.5","5":"196","6":"3900","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"51.3","4":"19.2","5":"193","6":"3650","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"45.4","4":"18.7","5":"188","6":"3525","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"52.7","4":"19.8","5":"197","6":"3725","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"45.2","4":"17.8","5":"198","6":"3950","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"46.1","4":"18.2","5":"178","6":"3250","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"51.3","4":"18.2","5":"197","6":"3750","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"46.0","4":"18.9","5":"195","6":"4150","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"51.3","4":"19.9","5":"198","6":"3700","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"46.6","4":"17.8","5":"193","6":"3800","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"51.7","4":"20.3","5":"194","6":"3775","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"47.0","4":"17.3","5":"185","6":"3700","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"52.0","4":"18.1","5":"201","6":"4050","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"45.9","4":"17.1","5":"190","6":"3575","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"50.5","4":"19.6","5":"201","6":"4050","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"50.3","4":"20.0","5":"197","6":"3300","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"58.0","4":"17.8","5":"181","6":"3700","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"46.4","4":"18.6","5":"190","6":"3450","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"49.2","4":"18.2","5":"195","6":"4400","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"42.4","4":"17.3","5":"181","6":"3600","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"48.5","4":"17.5","5":"191","6":"3400","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"43.2","4":"16.6","5":"187","6":"2900","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"50.6","4":"19.4","5":"193","6":"3800","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"46.7","4":"17.9","5":"195","6":"3300","7":"female","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"52.0","4":"19.0","5":"197","6":"4150","7":"male","8":"2007"},{"1":"Chinstrap","2":"Dream","3":"50.5","4":"18.4","5":"200","6":"3400","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"49.5","4":"19.0","5":"200","6":"3800","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"46.4","4":"17.8","5":"191","6":"3700","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"52.8","4":"20.0","5":"205","6":"4550","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"40.9","4":"16.6","5":"187","6":"3200","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"54.2","4":"20.8","5":"201","6":"4300","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"42.5","4":"16.7","5":"187","6":"3350","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"51.0","4":"18.8","5":"203","6":"4100","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"49.7","4":"18.6","5":"195","6":"3600","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"47.5","4":"16.8","5":"199","6":"3900","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"47.6","4":"18.3","5":"195","6":"3850","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"52.0","4":"20.7","5":"210","6":"4800","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"46.9","4":"16.6","5":"192","6":"2700","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"53.5","4":"19.9","5":"205","6":"4500","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"49.0","4":"19.5","5":"210","6":"3950","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"46.2","4":"17.5","5":"187","6":"3650","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"50.9","4":"19.1","5":"196","6":"3550","7":"male","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"45.5","4":"17.0","5":"196","6":"3500","7":"female","8":"2008"},{"1":"Chinstrap","2":"Dream","3":"50.9","4":"17.9","5":"196","6":"3675","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.8","4":"18.5","5":"201","6":"4450","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.1","4":"17.9","5":"190","6":"3400","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"49.0","4":"19.6","5":"212","6":"4300","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"51.5","4":"18.7","5":"187","6":"3250","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"49.8","4":"17.3","5":"198","6":"3675","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"48.1","4":"16.4","5":"199","6":"3325","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"51.4","4":"19.0","5":"201","6":"3950","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"45.7","4":"17.3","5":"193","6":"3600","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.7","4":"19.7","5":"203","6":"4050","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"42.5","4":"17.3","5":"187","6":"3350","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"52.2","4":"18.8","5":"197","6":"3450","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"45.2","4":"16.6","5":"191","6":"3250","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"49.3","4":"19.9","5":"203","6":"4050","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.2","4":"18.8","5":"202","6":"3800","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"45.6","4":"19.4","5":"194","6":"3525","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"51.9","4":"19.5","5":"206","6":"3950","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"46.8","4":"16.5","5":"189","6":"3650","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"45.7","4":"17.0","5":"195","6":"3650","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"55.8","4":"19.8","5":"207","6":"4000","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"43.5","4":"18.1","5":"202","6":"3400","7":"female","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"49.6","4":"18.2","5":"193","6":"3775","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.8","4":"19.0","5":"210","6":"4100","7":"male","8":"2009"},{"1":"Chinstrap","2":"Dream","3":"50.2","4":"18.7","5":"198","6":"3775","7":"female","8":"2009"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> ] ] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 08] Color vs. Fill Some `geom_*()` functions take the `fill` argument instead of `color` .leftcol[ .small[Build a bar-graph using `geom_bar()` using .green[local] aesthetic mapping] .small[Map `sex` to the `x` axis and `y` to `fill`] .code60[ ```r ggplot(data = penguins_no_miss) + geom_bar(mapping = aes(x = sex, * fill = species)) + labs_sex_vs_species ``` ] .small[Don't forget the labels!] ] -- .rightcol[ <img src="images/g08-geom_bar-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 09] Bar position Stacked bar-graphs make it difficult to do side-by-side comparisons using the `y` axis .leftcol[ .small[Using the same code as .red[graph 08], add the `position = "dodge"` argument *outside* the `aes()` function] .code60[ ```r ggplot(data = penguins_no_miss) + geom_bar(mapping = aes(x = sex, fill = species), * position = "dodge") + labs_sex_vs_species ``` ] ] -- .rightcol[ <img src="images/g08-dodge-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 10] Histograms (special bar-graphs) The `geom_histogram()` function uses 'bins' to represent counts for each value .leftcol[ .small[Create new labels] .code50[ ```r labs_bodymass_vs_species <- ggplot2::labs( title = "Body mass by species of Palmer penguins", subtitle = "Counts for adult foraging penguins", x = "Body Mass (grams)", fill = "Species") ``` ] .small[Create a histogram of `body_mass_g`, colored (filled) by `species`] .code50[ ```r ggplot(data = penguins) + geom_histogram( * mapping = aes(x = body_mass_g, * fill = species)) + labs_bodymass_vs_species ``` ] ] -- .rightcol[ .small[Notice the overlapping distributions of `body_mass_g`] <img src="images/g10-hist-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 11] Density plots Density plots are also great for comparing overlapping distributions .leftcol[ .small[Create a density plot with `geom_density()`] .small[Change the color saturation by setting .red[alpha] to `1/2`] .code60[ ```r ggplot(data = penguins) + geom_density( mapping = aes(x = body_mass_g, fill = species), * alpha = 1/2) + labs_bodymass_vs_species ``` ] ] -- .rightcol[ <img src="images/g11-alpha-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> .small[Also check out [ridgeline plots](https://mjfrigaard.github.io/odsc-ggplot2-2022/ggplot2-graph gallery.html#74)] ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Mapping vs. setting aesthetics]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Mapping vs. setting .leftcol[ .small[ The last few graphs have mapped aesthetics inside and outside the `aes()` function ] .code40[ ```r ggplot(data = penguins_no_miss) + geom_point( mapping = aes(x = bill_length_mm, y = flipper_length_mm, * color = sex)) + # inside labs_bill_vs_flippper ``` <img src="images/map-aes-1.png" width="90%" height="90%" style="display: block; margin: auto;" /> ] ] -- .rightcol[ .small[ Inside the `aes()` function is 'mapping', outside the `aes()` function is 'setting' ] .code40[ ```r ggplot(data = penguins_no_miss) + geom_point( mapping = aes(x = bill_length_mm, y = flipper_length_mm), * color = "dodgerblue") + # outside labs_bill_vs_flippper ``` <img src="images/set-aes-1.png" width="90%" height="90%" style="display: block; margin: auto;" /> ] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Mapping vs. setting <br> ### From [`ggplot2` book](https://ggplot2-book.org/layers.html#setting-mapping) > .large[.blue[*If you want appearance to be governed by a variable, put the specification inside `aes()`; if you want override the default size or colour, put the value outside of `aes()`.*]] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 12] Setting graph aesthetics Change the code below to make the points `"firebrick"` red .leftcol[ .small[Create labels] .code50[ ```r labs_body_mass_vs_bill_depth <- ggplot2::labs( title = "Body mass and bill depth of Palmer penguins", subtitle = "Size measurements for adult foraging penguins", x = "Body mass (mm)", y = "Bill depth (mm)") ``` ] .small[What color will the points be on this graph?] .code50[ ```r ggplot(data = penguins) + geom_point( mapping = aes(x = body_mass_g, y = bill_depth_mm, color = "firebrick")) + labs_body_mass_vs_bill_depth ``` ] ] -- .rightcol[ <img src="images/g12-set-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> .small[TIP: the legend tells us `geom_point()` is looking for a mapped variable in the penguins dataset named `"firebrick"`] ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Combining layers]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 13] New layer, new data, no problem Each `geom_*()` function also has a `data` argument, so we can supply new data at each layer Create a small dataset with max values from `bill_length_mm`, `bill_depth_mm`, `flipper_length_mm` and `body_mass_g` .leftcol[ .small[Create a dataset of the max body mass and bill depth (`big_penguins`)] .code50[ ```r big_penguins <- bind_rows( slice_max(.data = penguins, bill_length_mm, n = 1), slice_max(.data = penguins, bill_depth_mm, n = 1), slice_max(.data = penguins, flipper_length_mm, n = 1), slice_max(.data = penguins, body_mass_g, n = 1)) ``` ] ] -- .rightcol[ .small[Create data `label` and `source`] .code40[ ```r big_penguins <- mutate(.data = big_penguins, label = case_when( bill_length_mm == 59.6 ~ paste0("long bill = ", bill_length_mm), bill_depth_mm == 21.5 ~ paste0("deep bill = ", bill_depth_mm), flipper_length_mm == 231 ~ paste0("big flipper = ", flipper_length_mm), body_mass_g == 6300 ~ paste0("big bird = ", body_mass_g)), source = case_when( bill_length_mm == 59.6 ~ "max bill length", bill_depth_mm == 21.5 ~ "max bill depth", flipper_length_mm == 231 ~ "max flipper length", body_mass_g == 6300 ~ "max body mass")) ``` ] ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Our label dataset ### View `label` and `source` from `big_penguins` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["label"],"name":[1],"type":["chr"],"align":["left"]},{"label":["source"],"name":[2],"type":["chr"],"align":["left"]}],"data":[{"1":"long bill = 59.6","2":"max bill length"},{"1":"deep bill = 21.5","2":"max bill depth"},{"1":"big flipper = 231","2":"max flipper length"},{"1":"big bird = 6300","2":"max body mass"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> ### **Objective:** Create a scatter-plot to show the relationship between body mass, flipper length, and bill length. --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 13] Layer 1 Create layer 1 with `geom_point()` using `size` .leftcol40[ .small[Create labels] .code50[ ```r labs_bodymass_bill_depth_flipper_length <- labs( title = "Body mass, flipper length & bill depth", subtitle = "Size measures Palmer penguins", x = "Bill depth (mm)", y = "Flipper length (mm)", size = "Body mass (g)") ``` ] .small[Add new layer with new data] .code50[ ```r ggplot(data = penguins_no_miss) + # layer 1 geom_point( mapping = aes(x = bill_depth_mm, y = flipper_length_mm, size = body_mass_g), alpha = 1/2) + # labels labs_bodymass_bill_depth_flipper_length ``` ] ] -- .rightcol60[ <img src="images/g13_geom_point_layer_01-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 14] Layer 2 Create layer 2 with another `geom_point()` using `color` and `size` .leftcol40[ .small[Set the `data` argument to `big_penguins`] .small[Use `scale_size()` to adjust point scaling] .code50[ ```r ggplot(data = penguins_no_miss) + geom_point( mapping = aes(x = bill_depth_mm, y = flipper_length_mm, size = body_mass_g), alpha = 1/2) + # layer 2 geom_point(data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, # color by source color = source, size = body_mass_g)) + # re-scale scale_size(range = c(1, 5)) + # labels labs_bodymass_bill_depth_flipper_length ``` ] ] -- .rightcol60[ <img src="images/g14_geom_point_layer_02-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 15] Label 3 (max values) Add layer 3 with the `geom_label_repel()` function from [`ggrepel`](https://cran.r-project.org/web/packages/ggrepel/vignettes/ggrepel.html) .leftcol40[ .small[Add layer for `label`s in `big_penguins`] .code40[ ```r ggplot(data = penguins_no_miss) + geom_point( mapping = aes(x = bill_depth_mm, y = flipper_length_mm, size = body_mass_g), alpha = 1/2) + geom_point(data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, color = source, size = body_mass_g), # remove legend show.legend = FALSE) + # rescale scale_size(range = c(1, 5)) + # layer 3 ggrepel::geom_label_repel( data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, label = label)) + # labels labs_bodymass_bill_depth_flipper_length ``` ] ] -- .rightcol60[ <img src="images/g15_geom_label_repel-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Facets]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Facets From [`ggplot2` book](https://ggplot2-book.org/facet.html) > .large[.blue[*Small multiples are a powerful tool for exploratory data analysis: you can rapidly compare patterns in different parts of the data and see whether they are the same or different.*]] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # Facets = small multiples In the previous graph, we used multiple aesthetics (`color`, `size`, `shape`) Can we explore these relationships by `sex` or `species`? .leftcol[ .small[Store graph 15 in `ggp_penguin_measures`] .code60[ ```r ggp_penguin_measures <- ggplot(data = penguins_no_miss) + geom_point( mapping = aes(x = bill_depth_mm, y = flipper_length_mm, size = body_mass_g), alpha = 1/3) + geom_point(data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, color = source, size = body_mass_g), show.legend = FALSE) + scale_size(range = c(1, 5)) ``` ] ] -- .rightcol[ ```r ggp_penguin_measures ``` <img src="images/g16_ggp_penguin_measures-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 16] Facet by `sex` Use `facet_wrap()` to view our previous graph by `sex` .leftcol40[ .small[`facet_wrap()` uses `~ [var]` ] .code50[ ```r ggp_penguin_measures + ggrepel::geom_label_repel( data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, label = label), # adjust size size = 2) + # facet by sex facet_wrap(. ~ sex) + # labels labs_bodymass_bill_depth_flipper_length ``` ] ] -- .rightcol60[ <img src="images/g16_facet_01-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # .red[graph 17] Facet by `species` Change `facet_wrap()` to build graphs by `species` and add theme .leftcol40[ .small[Change `facet_wrap()` to `~ species`] .small[Add `theme_minimal()`] .code50[ ```r ggp_penguin_measures + ggrepel::geom_label_repel( data = big_penguins, mapping = aes(x = bill_depth_mm, y = flipper_length_mm, label = label), size = 2) + # change to species facet_wrap(. ~ species) + # add theme theme_minimal() + # labels labs_bodymass_bill_depth_flipper_length ``` ] ] -- .rightcol60[ <img src="images/g17_facet_02-out-1.png" width="100%" height="100%" style="display: block; margin: auto;" /> ] --- class: center, middle background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # **.fancy[.darkblue[.large[Recap]]]** --- class: left, top, inverse background-image: url(images/ODSC_Logo_2020.png) background-position: 97% 6% background-size: 8% # What we've covered .leftcol[ ### 1. Build labels (set your expectations) ### 2. View data before building any graphs ### 3. Building graphs layer-by-layer (data, mapping, geom) ] .rightcol[ ### 4. Mapping variables to graph elements (color, position, size, etc) ### 5. Extending graphs by combining layers ### 6. Using facets to explore relationships ] --- class: center, middle, inverse, no-slide-number background-image: url(images/ODSC_Logo_2020.png) background-position: 95% 8% background-size: 12% # Thanks! .footer-large[ .right[ [@mjfrigaard
](http://twitter.com/mjfrigaard)<br> [@mjfrigaard
](http://github.com/mjfrigaard)<br> [mjfrigaard@pm.e
](mailto:mjfrigaard@pm.me)<br> [What does "λέξις" mean?](https://jhelvy.github.io/lexis/index.html#what-does-%CE%BB%CE%AD%CE%BE%CE%B9%CF%82-mean) ]]