├── .gitattributes ├── .gitignore ├── 01_make-gapminder-color-scheme.r ├── 02-merge-color-into-data.r ├── LICENSE ├── README.md ├── figure ├── colors-unnamed-chunk-10-1.png ├── colors-unnamed-chunk-10.png ├── colors-unnamed-chunk-3-1.png ├── colors-unnamed-chunk-3.png ├── colors-unnamed-chunk-4-1.png ├── colors-unnamed-chunk-4.png ├── colors-unnamed-chunk-5-1.png ├── colors-unnamed-chunk-5.png ├── colors-unnamed-chunk-6-1.png ├── colors-unnamed-chunk-6.png ├── colors-unnamed-chunk-8-1.png ├── colors-unnamed-chunk-8.png ├── scatterplot-unnamed-chunk-10-1.png ├── scatterplot-unnamed-chunk-10.png ├── scatterplot-unnamed-chunk-101.png ├── scatterplot-unnamed-chunk-102.png ├── scatterplot-unnamed-chunk-11-1.png ├── scatterplot-unnamed-chunk-11-2.png ├── scatterplot-unnamed-chunk-11.png ├── scatterplot-unnamed-chunk-111.png ├── scatterplot-unnamed-chunk-112.png ├── scatterplot-unnamed-chunk-12-1.png ├── scatterplot-unnamed-chunk-12-2.png ├── scatterplot-unnamed-chunk-12-3.png ├── scatterplot-unnamed-chunk-12.png ├── scatterplot-unnamed-chunk-13-1.png ├── scatterplot-unnamed-chunk-13-2.png ├── scatterplot-unnamed-chunk-13.png ├── scatterplot-unnamed-chunk-131.png ├── scatterplot-unnamed-chunk-132.png ├── scatterplot-unnamed-chunk-14-1.png ├── scatterplot-unnamed-chunk-14-2.png ├── scatterplot-unnamed-chunk-141.png ├── scatterplot-unnamed-chunk-142.png ├── scatterplot-unnamed-chunk-143.png ├── scatterplot-unnamed-chunk-15-1.png ├── scatterplot-unnamed-chunk-15-2.png ├── scatterplot-unnamed-chunk-15-3.png ├── scatterplot-unnamed-chunk-15.png ├── scatterplot-unnamed-chunk-151.png ├── scatterplot-unnamed-chunk-152.png ├── scatterplot-unnamed-chunk-153.png ├── scatterplot-unnamed-chunk-16-1.png ├── scatterplot-unnamed-chunk-16-2.png ├── scatterplot-unnamed-chunk-16-3.png ├── scatterplot-unnamed-chunk-16.png ├── scatterplot-unnamed-chunk-17-1.png ├── scatterplot-unnamed-chunk-17.png ├── scatterplot-unnamed-chunk-18-1.png ├── scatterplot-unnamed-chunk-18-2.png ├── scatterplot-unnamed-chunk-18.png ├── scatterplot-unnamed-chunk-19-1.png ├── scatterplot-unnamed-chunk-19-2.png ├── scatterplot-unnamed-chunk-19-3.png ├── scatterplot-unnamed-chunk-19.png ├── scatterplot-unnamed-chunk-2-1.png ├── scatterplot-unnamed-chunk-2-2.png ├── scatterplot-unnamed-chunk-20-1.png ├── scatterplot-unnamed-chunk-21-1.png ├── scatterplot-unnamed-chunk-22-1.png ├── scatterplot-unnamed-chunk-23-1.png ├── scatterplot-unnamed-chunk-24-1.png ├── scatterplot-unnamed-chunk-3-1.png ├── scatterplot-unnamed-chunk-3.png ├── scatterplot-unnamed-chunk-4-1.png ├── scatterplot-unnamed-chunk-4.png ├── scatterplot-unnamed-chunk-41.png ├── scatterplot-unnamed-chunk-42.png ├── scatterplot-unnamed-chunk-5-1.png ├── scatterplot-unnamed-chunk-5.png ├── scatterplot-unnamed-chunk-61.png ├── scatterplot-unnamed-chunk-62.png ├── scatterplot-unnamed-chunk-7-1.png ├── scatterplot-unnamed-chunk-7-2.png ├── scatterplot-unnamed-chunk-7.png ├── scatterplot-unnamed-chunk-71.png ├── scatterplot-unnamed-chunk-72.png ├── scatterplot-unnamed-chunk-8-1.png ├── scatterplot-unnamed-chunk-8.png ├── scatterplot-unnamed-chunk-81.png ├── scatterplot-unnamed-chunk-82.png ├── scatterplot-unnamed-chunk-83.png ├── scatterplot-unnamed-chunk-9-1.png ├── scatterplot-unnamed-chunk-9-2.png ├── scatterplot-unnamed-chunk-9-3.png ├── scatterplot-unnamed-chunk-9.png ├── scatterplot-unnamed-chunk-91.png ├── scatterplot-unnamed-chunk-92.png ├── scatterplot-unnamed-chunk-93.png ├── shock-awe-unnamed-chunk-4-1.png ├── shock-awe-unnamed-chunk-4-2.png ├── shock-awe-unnamed-chunk-41.png ├── shock-awe-unnamed-chunk-42.png ├── stripplot-unnamed-chunk-3-1.png ├── stripplot-unnamed-chunk-3.png ├── stripplot-unnamed-chunk-4-1.png ├── stripplot-unnamed-chunk-4.png ├── stripplot-unnamed-chunk-5-1.png ├── stripplot-unnamed-chunk-5.png ├── stripplot-unnamed-chunk-6-1.png ├── stripplot-unnamed-chunk-6.png ├── stripplot-unnamed-chunk-7-1.png ├── stripplot-unnamed-chunk-7.png ├── stripplot-unnamed-chunk-8-1.png ├── stripplot-unnamed-chunk-8.png ├── stripplot-unnamed-chunk-9-1.png ├── stripplot-unnamed-chunk-9.png ├── themes-unnamed-chunk-3-1.png ├── themes-unnamed-chunk-3.png ├── themes-unnamed-chunk-4-1.png ├── themes-unnamed-chunk-4.png ├── themes-unnamed-chunk-5-1.png ├── themes-unnamed-chunk-5.png ├── themes-unnamed-chunk-6-1.png ├── themes-unnamed-chunk-6.png ├── themes-unnamed-chunk-7-1.png ├── themes-unnamed-chunk-7-2.png ├── themes-unnamed-chunk-7-3.png ├── themes-unnamed-chunk-7-4.png ├── themes-unnamed-chunk-7-5.png ├── themes-unnamed-chunk-7-6.png ├── themes-unnamed-chunk-7-7.png ├── themes-unnamed-chunk-71.png ├── themes-unnamed-chunk-72.png ├── themes-unnamed-chunk-73.png ├── themes-unnamed-chunk-74.png ├── themes-unnamed-chunk-75.png ├── themes-unnamed-chunk-76.png ├── themes-unnamed-chunk-77.png ├── uni-factor-unnamed-chunk-10-1.png ├── uni-factor-unnamed-chunk-10.png ├── uni-factor-unnamed-chunk-3-1.png ├── uni-factor-unnamed-chunk-4-1.png ├── uni-factor-unnamed-chunk-4.png ├── uni-factor-unnamed-chunk-5-1.png ├── uni-factor-unnamed-chunk-5.png ├── uni-factor-unnamed-chunk-6-1.png ├── uni-factor-unnamed-chunk-6.png ├── uni-factor-unnamed-chunk-7-1.png ├── uni-factor-unnamed-chunk-7.png ├── uni-factor-unnamed-chunk-8-1.png ├── uni-factor-unnamed-chunk-9-1.png ├── uni-factor-unnamed-chunk-9.png ├── uni-quant-unnamed-chunk-10-1.png ├── uni-quant-unnamed-chunk-10-2.png ├── uni-quant-unnamed-chunk-101.png ├── uni-quant-unnamed-chunk-102.png ├── uni-quant-unnamed-chunk-11-1.png ├── uni-quant-unnamed-chunk-11.png ├── uni-quant-unnamed-chunk-12-1.png ├── uni-quant-unnamed-chunk-12-2.png ├── uni-quant-unnamed-chunk-12.png ├── uni-quant-unnamed-chunk-13-1.png ├── uni-quant-unnamed-chunk-14-1.png ├── uni-quant-unnamed-chunk-15-1.png ├── uni-quant-unnamed-chunk-2-1.png ├── uni-quant-unnamed-chunk-3-1.png ├── uni-quant-unnamed-chunk-3.png ├── uni-quant-unnamed-chunk-4-1.png ├── uni-quant-unnamed-chunk-4.png ├── uni-quant-unnamed-chunk-5-1.png ├── uni-quant-unnamed-chunk-5.png ├── uni-quant-unnamed-chunk-6-1.png ├── uni-quant-unnamed-chunk-6.png ├── uni-quant-unnamed-chunk-7-1.png ├── uni-quant-unnamed-chunk-7.png ├── uni-quant-unnamed-chunk-8-1.png ├── uni-quant-unnamed-chunk-8-2.png ├── uni-quant-unnamed-chunk-8.png ├── uni-quant-unnamed-chunk-9-1.png └── uni-quant-unnamed-chunk-9.png ├── from_yair_goldberg ├── 12-graphics.Rpres ├── 12-graphics.html ├── 13-more-graphics.Rpres └── 13-more-graphics.html ├── gapminder-continent-colors.tsv ├── gapminder-country-colors.pdf ├── gapminder-country-colors.png ├── gapminder-country-colors.tsv ├── gapminder-gganimate.gif ├── gapminder-gganimate.rmd ├── gapminder-ggplot2-colors.md ├── gapminder-ggplot2-colors.r ├── gapminder-ggplot2-scatterplot.md ├── gapminder-ggplot2-scatterplot.r ├── gapminder-ggplot2-shock-and-awe.md ├── gapminder-ggplot2-shock-and-awe.r ├── gapminder-ggplot2-stripplot.md ├── gapminder-ggplot2-stripplot.r ├── gapminder-ggplot2-themes.md ├── gapminder-ggplot2-themes.r ├── gapminder-ggplot2-univariate-factor.md ├── gapminder-ggplot2-univariate-factor.r ├── gapminder-ggplot2-univariate-quantitative.md ├── gapminder-ggplot2-univariate-quantitative.r ├── gapminderDataColorReadySorted.tsv ├── gapminderDataFiveYear.tsv └── ggplot2-tutorial-slides ├── README.Rmd ├── README.html ├── README.md ├── ggplot2-tutorial-slides.001.png ├── ggplot2-tutorial-slides.002.png ├── ggplot2-tutorial-slides.003.png ├── ggplot2-tutorial-slides.004.png ├── ggplot2-tutorial-slides.005.png ├── ggplot2-tutorial-slides.006.png ├── ggplot2-tutorial-slides.007.png ├── ggplot2-tutorial-slides.008.png ├── ggplot2-tutorial-slides.009.png ├── ggplot2-tutorial-slides.010.png ├── ggplot2-tutorial-slides.011.png ├── ggplot2-tutorial-slides.012.png ├── ggplot2-tutorial-slides.013.png ├── ggplot2-tutorial-slides.014.png ├── ggplot2-tutorial-slides.015.png ├── ggplot2-tutorial-slides.016.png ├── ggplot2-tutorial-slides.017.png ├── ggplot2-tutorial-slides.018.png ├── ggplot2-tutorial-slides.019.png ├── ggplot2-tutorial-slides.020.png ├── ggplot2-tutorial-slides.021.png ├── ggplot2-tutorial-slides.022.png ├── ggplot2-tutorial-slides.023.png ├── ggplot2-tutorial-slides.024.png ├── ggplot2-tutorial-slides.025.png ├── ggplot2-tutorial-slides.026.png ├── ggplot2-tutorial-slides.027.png ├── ggplot2-tutorial-slides.028.png ├── ggplot2-tutorial-slides.029.png ├── ggplot2-tutorial-slides.030.png ├── ggplot2-tutorial-slides.031.png ├── ggplot2-tutorial-slides.032.png ├── ggplot2-tutorial-slides.033.png ├── ggplot2-tutorial-slides.034.png ├── ggplot2-tutorial-slides.035.png ├── ggplot2-tutorial-slides.036.png ├── ggplot2-tutorial-slides.037.png ├── ggplot2-tutorial-slides.038.png ├── ggplot2-tutorial-slides.039.png ├── ggplot2-tutorial-slides.040.png ├── ggplot2-tutorial-slides.041.png ├── ggplot2-tutorial-slides.042.png ├── ggplot2-tutorial-slides.043.png ├── ggplot2-tutorial-slides.044.png ├── ggplot2-tutorial-slides.045.png ├── ggplot2-tutorial-slides.046.png ├── ggplot2-tutorial-slides.047.png ├── ggplot2-tutorial-slides.048.png ├── ggplot2-tutorial-slides.049.png ├── ggplot2-tutorial-slides.050.png ├── ggplot2-tutorial-slides.051.png ├── ggplot2-tutorial-slides.052.png ├── ggplot2-tutorial-slides.053.png ├── ggplot2-tutorial-slides.054.png ├── ggplot2-tutorial-slides.055.png ├── ggplot2-tutorial-slides.056.png ├── ggplot2-tutorial-slides.057.png └── ggplot2-tutorial-slides.pdf /.gitattributes: -------------------------------------------------------------------------------- 1 | from_yair_goldberg/*.html linguist-documentation 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | *.Rproj 5 | *.key 6 | gapminder-ggplot2-*.html 7 | gapminder-ggplot2-*.Rmd 8 | README.html 9 | -------------------------------------------------------------------------------- /01_make-gapminder-color-scheme.r: -------------------------------------------------------------------------------- 1 | library(plyr) 2 | library(RColorBrewer) # will use for color-coding 3 | # continent 4 | 5 | ## data import from local file 6 | gDat <- read.delim("gapminderDataFiveYear.tsv") 7 | 8 | ## reach out and touch the data 9 | str(gDat) # 'data.frame': 1704 obs. of 6 variables: 10 | 11 | ## continent-level info 12 | (cDat <- aggregate(country ~ continent, gDat, 13 | function(x) length(unique(x)))) 14 | (nCont <- nrow(cDat)) 15 | 16 | ## map continent and country into colors 17 | 18 | ## choose a range of colors for each continent 19 | #display.brewer.all(type = "div") 20 | 21 | color_anchors <- 22 | list(Africa = brewer.pal(n = 11, 'PuOr')[1:5], # orange/brown/gold 23 | Americas = brewer.pal(n = 11, 'RdYlBu')[1:5], # red 24 | Asia = brewer.pal(n = 11, 'PRGn')[1:5], # purple 25 | Europe = brewer.pal(n = 11, 'PiYG')[11:7], # green 26 | Oceania = brewer.pal(n = 11, 'RdYlBu')[11:10]) # blue 27 | 28 | ## retain the first or darkest color to represent the whole continent 29 | cDat$color <- laply(color_anchors, "[", 1) 30 | 31 | ## expand into palettes big enough to cover each country in a 32 | ## continent 33 | country_colors <- ddply(gDat, ~ continent, function(x) { 34 | the_continent <- x$continent[1] 35 | x <- droplevels(x) 36 | countriesBigToSmall <- 37 | with(x, levels(reorder(country, desc(pop), max))) 38 | colorFun <- colorRampPalette(color_anchors[[the_continent]]) 39 | return(data.frame(country = I(countriesBigToSmall), 40 | color = I(colorFun(length(countriesBigToSmall))))) 41 | }) 42 | 43 | ## make a nice figure of my color scheme 44 | 45 | ## fiddly parameters that control printing of country names 46 | charLimit <- 12 47 | xFudge <- 0.05 48 | jCex <- 0.75 49 | 50 | ## store figure making code as a function so can make pdf and png 51 | make_figure <- function() { 52 | plot(c(0, nCont), c(0, 1), type = "n", 53 | xlab = "", ylab="", xaxt = "n", yaxt = "n", bty = "n", 54 | main = "Gapminder Color Scheme") 55 | for(i in seq_len(nCont)) { 56 | thisCont <- cDat$continent[i] 57 | nCols <- with(cDat, country[continent == thisCont]) 58 | yFudge <- 0.1/nCols 59 | foo <- seq(from = 0, to = 1, length = nCols + 1) 60 | rect(xleft = i - 1, 61 | ybottom = foo[-(nCols + 1)], 62 | xright = i, 63 | ytop = foo[-1], 64 | col = with(country_colors, color[continent == thisCont])) 65 | text(x = i - 1 + xFudge, 66 | y = foo[-(nCols + 1)] + yFudge, 67 | labels = with(country_colors, 68 | substr(country[continent == thisCont], 1, charLimit)), 69 | adj = c(0, 0), cex = jCex) 70 | } 71 | mtext(cDat$continent, side = 3, at = seq_len(nCont) - 0.5) 72 | mtext(c("smallest\npop", "largest\npop"), 73 | side = 2, at = c(0.9, 0.1), las = 1) 74 | } 75 | 76 | op <- par(mar = c(1, 4, 6, 1) + 0.1) 77 | make_figure() 78 | par(op) 79 | 80 | png("gapminder-country-colors.png", 81 | width = 7, height = 10, units = "in", res = 200) 82 | op <- par(mar = c(1, 4, 6, 1) + 0.1) 83 | make_figure() 84 | dev.off() 85 | par(op) 86 | 87 | pdf("gapminder-country-colors.pdf", 88 | width = 7, height = 10) 89 | op <- par(mar = c(1, 4, 6, 1) + 0.1) 90 | make_figure() 91 | dev.off() 92 | par(op) 93 | 94 | write.table(country_colors, "gapminder-country-colors.tsv", 95 | quote = FALSE, sep = "\t", row.names = FALSE) 96 | 97 | write.table(cDat, "gapminder-continent-colors.tsv", 98 | quote = FALSE, sep = "\t", row.names = FALSE) 99 | 100 | -------------------------------------------------------------------------------- /02-merge-color-into-data.r: -------------------------------------------------------------------------------- 1 | library(plyr) 2 | 3 | ## data import from local file 4 | gDat <- read.delim("gapminderDataFiveYear.tsv") 5 | 6 | country_colors <- read.delim("gapminder-country-colors.tsv", 7 | colClasses = list(color = "character")) 8 | str(country_colors) 9 | ## 'data.frame': 142 obs. of 3 variables: 10 | ## $ continent: Factor w/ 5 levels "Africa","Americas",..: 1 1 1 1 1 1 1 1 1 1 ... 11 | ## $ country : Factor w/ 142 levels "Afghanistan",..: 95 39 43 28 118 121 127 6.. 12 | ## $ color : chr "#7F3B08" "#833D07" "#873F07" "#8B4107" ... 13 | 14 | ## insert color as a variable in gDat 15 | gDat <- merge(gDat, country_colors) 16 | 17 | ## Sort by year (increasing) and population (decreasing) 18 | ## Why? So larger countries will be plotted "under" smaller ones. 19 | gDatOrdered <- arrange(gDat, year, desc(pop)) 20 | 21 | write.table(gDatOrdered, "gapminderDataColorReadySorted.tsv", 22 | quote = FALSE, sep = "\t", row.names = FALSE) 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Jennifer (Jenny) Bryan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ggplot2-tutorial 2 | ================ 3 | 4 | Teaching materials for the R package ggplot2 5 | 6 | Offered 7 | 8 | * Thursday May 15, 2014 [under the auspices of the Vancouver R Users Group and hosted at the BC Centres for Disease Control](http://www.meetup.com/Vancouver-R-Users-Group-data-analysis-statistics/events/164489182/) 9 | * Thursday May 14, 2015 [as part of the Workshop on Big Data in Environmental Science at UBC](http://www.pims.math.ca/scientific-event/150511-bdes) 10 | * Tuesday July 19, 2016 [Data Carpentry at the University of Zurich](https://markrobinsonuzh.github.io/2016-07-18-zurich/) 11 | 12 | There are some slides. 13 | 14 | * Directory for everything re: the slides: [ggplot2-tutorial-slides](../master/ggplot2-tutorial-slides/) 15 | - Keynote file 16 | - PDF 17 | - Individual slides as PNGs (scroll through README to see 'em all) 18 | * [Slides on Speakerdeck](https://speakerdeck.com/jennybc/ggplot2-tutorial) 19 | 20 | 21 | We do live coding together. Indicative content: 22 | 23 | * Scatterplots: [demo](../master/gapminder-ggplot2-scatterplot.md) | [R source](../master/gapminder-ggplot2-scatterplot.r) 24 | * Stripplots: [demo](../master/gapminder-ggplot2-stripplot.md) | [R source](../master/gapminder-ggplot2-stripplot.r) 25 | * Exploring distribution of a quantitative variable: [demo](../master/gapminder-ggplot2-univariate-quantitative.md) | [R source](../master/gapminder-ggplot2-univariate-quantitative.r) 26 | * Drawing bars: [demo](../master/gapminder-ggplot2-univariate-factor.md) | [R source](../master/gapminder-ggplot2-univariate-factor.r) 27 | * Change overall look and feel via themes: [demo](../master/gapminder-ggplot2-themes.md) | [R source](../master/gapminder-ggplot2-themes.r) 28 | * Take control of a qualitative color scheme: [demo](../master/gapminder-ggplot2-colors.md) | [R source](../master/gapminder-ggplot2-colors.r) 29 | * Bubble and line plots, lots of customization: [demo](../master/gapminder-ggplot2-shock-and-awe.md) | [R source](../master/gapminder-ggplot2-shock-and-awe.r) 30 | 31 | 32 | Links and references 33 | 34 | * All the figure-making content in my [STAT545 course](http://stat545-ubc.github.io/graph00_index.html) 35 | * [ggplot2 on github](https://github.com/hadley/ggplot2) 36 | * [ggplot2 "homepage"](http://ggplot2.org) 37 | * [ggplot2 online docs](http://docs.ggplot2.org/current/) 38 | * [The R Graphics Cookbook](http://shop.oreilly.com/product/0636920023135.do) by Winston Chang. 39 | * The [graphs section](http://www.cookbook-r.com/Graphs/) of Winston Chang's website Cookbook for R. The book listed above contains much more material, but the website is good too. 40 | * [ggplot2: Elegant Graphics for Data Analysis](http://www.amazon.com/dp/0387981403/ref=cm_sw_su_dp?tag=ggplot2-20) by Hadley Wickham. [Book's companion website](http://ggplot2.org/book/) offers one R script per chapter, providing the code used in the book. 41 | * [A quick introduction to ggplot2](http://inundata.org/2013/04/10/a-quick-introduction-to-ggplot2/) by Karthik Ram. Slides and code from a 2 hour talk/hands on presentation for ggplot2 beginners. 42 | * Nine simple ways to make it easier to (re)use your data by Ethan P White, Elita Baldridge, Zachary T. Brym, Kenneth J. Locey, Daniel J. McGlinn, Sarah R. Supp. Ideas in Ecology and Evolution 6(2): 1–10, 2013. doi:10.4033/iee.2013.6b.6.f . Section 4 "Use Standard Data Formats" is especially good reading. 43 | * Tidy data by Hadley Wickham. Submitted to The Journal of Statistical Software. Preprint available . 44 | * RStudio's Cheat Sheets: . Especially relevant: 45 | - Data wrangling 46 | - Data visualization 47 | 48 | To add: 49 | 50 | * writing figures to file -- covered in the slides only for now 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-10.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-3.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-6.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /figure/colors-unnamed-chunk-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/colors-unnamed-chunk-8.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-10.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-101.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-102.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-11-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-11-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-11.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-111.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-112.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-12-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-12-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-12-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-12-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-12.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-13-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-13-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-13.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-131.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-131.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-132.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-132.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-14-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-14-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-141.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-141.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-142.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-142.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-143.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-143.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-15-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-15-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-15-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-15-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-15.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-151.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-151.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-152.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-153.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-16-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-16-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-16-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-16-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-16.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-17.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-18-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-18-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-18.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-19-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-19-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-19-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-19-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-19.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-2-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-2-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-41.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-42.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-61.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-62.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-7-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-7-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-7.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-71.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-72.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-8.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-81.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-81.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-82.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-82.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-83.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-83.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-9-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-9-2.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-9-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-9-3.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-9.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-91.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-91.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-92.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-92.png -------------------------------------------------------------------------------- /figure/scatterplot-unnamed-chunk-93.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/scatterplot-unnamed-chunk-93.png -------------------------------------------------------------------------------- /figure/shock-awe-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/shock-awe-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/shock-awe-unnamed-chunk-4-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/shock-awe-unnamed-chunk-4-2.png -------------------------------------------------------------------------------- /figure/shock-awe-unnamed-chunk-41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/shock-awe-unnamed-chunk-41.png -------------------------------------------------------------------------------- /figure/shock-awe-unnamed-chunk-42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/shock-awe-unnamed-chunk-42.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-3.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-6.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-7.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-8.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /figure/stripplot-unnamed-chunk-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/stripplot-unnamed-chunk-9.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-3.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-6.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-2.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-3.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-4.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-5.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-6.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-7-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-7-7.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-71.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-72.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-73.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-73.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-74.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-74.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-75.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-76.png -------------------------------------------------------------------------------- /figure/themes-unnamed-chunk-77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/themes-unnamed-chunk-77.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-10.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-6.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-7.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /figure/uni-factor-unnamed-chunk-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-factor-unnamed-chunk-9.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-10-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-10-2.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-101.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-102.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-11.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-12-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-12-2.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-12.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-3.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-4.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-5.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-6.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-7.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-8-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-8-2.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-8.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /figure/uni-quant-unnamed-chunk-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/figure/uni-quant-unnamed-chunk-9.png -------------------------------------------------------------------------------- /from_yair_goldberg/12-graphics.Rpres: -------------------------------------------------------------------------------- 1 | 4 | 5 | Graphics 6 | ==== 7 | 8 | Agenda 9 | === 10 | 11 | - Grammer of Graphics 12 | 13 | - Using ggplot2 14 | 15 | The following presentation is based on the [ggplot2 tutorial](https://github.com/jennybc/ggplot2-tutorial) written by Prof. Jennifer Bryan. 16 | 17 | ggplot2 (wiki) 18 | === 19 | 20 | - ggplot2 is a data visualization package 21 | 22 | - Created by Hadley Wickham in 2005 23 | 24 | - ggplot2 is an implementation of Leland Wilkinson's Grammar of Graphics scheme 25 | 26 | - ggplot2 has grown in use to become one of the most popular R packages. 27 | 28 | Grammar of Graphics 29 | === 30 | 31 | **Elements** 32 | 33 | - `data`: The data that you want to visualise 34 | 35 | - `aes`: Aesthetic mappings 36 | describing how variables in the data are mapped to aesthetic attributes 37 | 38 | + horizontalposition (`x`) 39 | + vertical position (`y`) 40 | + colour 41 | + size 42 | 43 | Grammar of Graphics 44 | === 45 | 46 | **Elements** 47 | 48 | - `geoms`: Geometric objects that represent what you actually see on 49 | the plot 50 | + points 51 | + lines 52 | + polygons 53 | + bars 54 | 55 | Grammar of Graphics 56 | === 57 | 58 | **Elements** 59 | 60 | 61 | - `stats`: Statistics transformations 62 | + binning and counting observations to create a histogram, 63 | + summarising a 2d relationship with a linear model 64 | + `stats` are optional 65 | 66 | 67 | Grammar of Graphics 68 | === 69 | 70 | **Elements** 71 | 72 | - `scales`: related the data to the aesthetic 73 | 74 | - `coord`: A coordinate systemthat describes how data coordinates are 75 | mapped to the plane of the graphic. 76 | 77 | - `facet`: A faceting specification describes how to break up the data into subsets. 78 | 79 | Grammar of Graphics 80 | === 81 | 82 | **Layers** 83 | 84 | A layer is composed of four parts: 85 | - data and aesthetic mapping, 86 | - a statistical transformation (`stat`), 87 | - a geometric object (`geom`) 88 | - a position adjustment. 89 | 90 | A plot is constructed by adding layers to each other 91 | 92 | ggplot2 93 | === 94 | 95 | Load the library 96 | ```{r} 97 | library(ggplot2) 98 | ``` 99 | 100 | Read data 101 | ```{r} 102 | gdURL <- "http://tiny.cc/gapminder" 103 | gDat <- read.table(file = gdURL,header=T,sep = "\t") 104 | str(gDat) 105 | ``` 106 | 107 | Scatterplot 108 | === 109 | Creating a plot object 110 | ```{r} 111 | p <- ggplot(gDat, aes(x = gdpPercap, y = lifeExp)) # just initializes 112 | ``` 113 | 114 | 115 | Scatterplot 116 | ```{r} 117 | p + geom_point() 118 | #p + layer(geom = "point") 119 | ``` 120 | 121 | Data transformation 122 | === 123 | Log transformation ... quick and dirty 124 | ```{r} 125 | ggplot(gDat, aes(x = log10(gdpPercap), y = lifeExp)) + geom_point() 126 | ``` 127 | 128 | Data transformation 129 | === 130 | A better way to log transform 131 | ```{r} 132 | p + geom_point() + scale_x_log10() 133 | ``` 134 | 135 | 136 | === 137 | Let's make that stick 138 | ```{r} 139 | p <- p + scale_x_log10() 140 | ``` 141 | 142 | common workflow: gradually build up the plot you want 143 | 144 | Re-define the object `p` as you develop "keeper" commands 145 | 146 | === 147 | Convey continent by color: MAP continent variable to aesthetic color 148 | ```{r} 149 | p + geom_point(aes(color = continent)) 150 | 151 | ``` 152 | 153 | === 154 | In full detail, up to now: 155 | ``` 156 | ggplot(gDat, aes(x = gdpPercap, y = lifeExp, color = continent)) + 157 | geom_point() + scale_x_log10() 158 | 159 | ``` 160 | 161 | === 162 | Address overplotting: SET alpha transparency and size to a value 163 | ```{r} 164 | p + geom_point(alpha = (1/3), size = 3) 165 | 166 | ``` 167 | 168 | Curves 169 | === 170 | Add a fitted curve or line 171 | ```{r} 172 | p + geom_point() + geom_smooth() 173 | ``` 174 | 175 | Curves 176 | === 177 | ```{r} 178 | p + geom_point() + geom_smooth(lwd = 3, 179 | se = FALSE) 180 | ``` 181 | 182 | Curves 183 | === 184 | ```{r} 185 | p + geom_point() + geom_smooth(lwd = 3, se = FALSE, method = "lm") 186 | 187 | ``` 188 | 189 | Curves 190 | === 191 | 192 | Return to continents: 193 | ```{r} 194 | p + aes(color = continent) + geom_point() + geom_smooth(lwd = 3, se = FALSE) 195 | ``` 196 | 197 | Facets 198 | === 199 | 200 | Facetting: another way to exploit a factor 201 | 202 | ```{r} 203 | p + geom_point(alpha = (1/3), size = 3) + facet_wrap(~ continent) 204 | 205 | ``` 206 | 207 | Facets 208 | === 209 | ```{r} 210 | p + geom_point(alpha = (1/3), size = 3) + facet_wrap(~ continent) + 211 | geom_smooth(lwd = 2, se = FALSE) 212 | ``` 213 | 214 | === 215 | 216 | Exercises: 217 | 218 | - Plot lifeExp against year 219 | 220 | - Make mini-plots, split out by continent 221 | 222 | - Add a fitted smooth and/or linear regression, with or without facetting 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | === 234 | 235 | Plot `lifeExp` against `year` 236 | 237 | ```{r} 238 | (p1 <- ggplot(gDat, aes(x = year, y = lifeExp)) + geom_point()) 239 | 240 | ``` 241 | 242 | === 243 | Make mini-plots, split out by continent 244 | ```{r} 245 | p1 + facet_wrap(~ continent) 246 | 247 | ``` 248 | 249 | === 250 | Add a fitted smooth and/or linear regression, without facetting 251 | ```{r} 252 | p1 + geom_smooth(se = FALSE, lwd = 2) + 253 | geom_smooth(se = FALSE, method ="lm", color = "orange", lwd = 2) 254 | ``` 255 | 256 | 257 | === 258 | Add a fitted smooth and/or linear regression, with facetting 259 | 260 | ```{r} 261 | p1+ geom_smooth(se = FALSE, lwd = 2) + 262 | facet_wrap(~ continent) 263 | 264 | ``` 265 | 266 | === 267 | Last bit on scatterplots 268 | 269 | - How can we "connect the dots" for one country? make a spaghetti plot? 270 | ```{r} 271 | p1 + facet_wrap(~ continent) + geom_line() # uh, no 272 | ``` 273 | 274 | === 275 | ```{r} 276 | p1 + facet_wrap(~ continent) + geom_line(aes(group = country)) # yes! 277 | ``` 278 | 279 | === 280 | 281 | ```{r} 282 | p1 + facet_wrap(~ continent) + geom_line(aes(group = country)) + 283 | geom_smooth(se = FALSE, lwd = 2) 284 | 285 | ``` 286 | 287 | 288 | Subsetting data 289 | === 290 | 291 | - `ggplot()` does not have a `subset =` argument 292 | 293 | - Do that 'on the fly' with `subset(..., subset = ...)` 294 | 295 | ```{r} 296 | ggplot(subset(gDat, country == "Zimbabwe"), 297 | aes(x = year, y = lifeExp)) + geom_line() + geom_point() 298 | 299 | ``` 300 | 301 | === 302 | Let just look at four countries 303 | ```{r} 304 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 305 | ggplot(subset(gDat, country %in% jCountries), 306 | aes(x = year, y = lifeExp, color = country)) + geom_line() + geom_point() 307 | ``` 308 | 309 | === 310 | When you really care, make your legend easy to navigate 311 | 312 | This means visual order = data order = factor level order 313 | 314 | ```{r} 315 | ggplot(subset(gDat, country %in% jCountries), 316 | aes(x = year, y = lifeExp, color = reorder(country, -1 * lifeExp, max))) + geom_line() + geom_point() 317 | 318 | ``` 319 | 320 | 321 | === 322 | Another approach to overplotting 323 | ```{r} 324 | ggplot(gDat, aes(x = gdpPercap, y = lifeExp)) + scale_x_log10() + geom_bin2d() 325 | 326 | ``` 327 | 328 | Stripplots 329 | === 330 | 331 | Stripplots: univariate scatterplots (but w/ ways to also convey 1+ factors) 332 | 333 | ```{r} 334 | ggplot(gDat, aes(x = continent, y = lifeExp)) + geom_point() 335 | ``` 336 | 337 | Stripplots 338 | === 339 | We have an overplotting problem; need to spread things out 340 | ```{r} 341 | ggplot(gDat, aes(x = continent, y = lifeExp)) + geom_jitter() 342 | 343 | ``` 344 | 345 | === 346 | We can have less jitter in `x`, no jitter in `y`, more alpha transparency 347 | ```{r} 348 | ggplot(gDat, aes(x = continent, y = lifeExp)) + 349 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 350 | 351 | ``` 352 | Boxplots 353 | === 354 | Boxplots -- covered properly elsewhere 355 | 356 | ```{r} 357 | ggplot(gDat, aes(x = continent, y = lifeExp)) + geom_boxplot() 358 | 359 | ``` 360 | Boxplots 361 | === 362 | Raw data AND boxplots 363 | ```{r} 364 | ggplot(gDat, aes(x = continent, y = lifeExp)) + 365 | geom_boxplot(outlier.colour = "hotpink") + 366 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 367 | 368 | ``` 369 | 370 | === 371 | Superpose a statistical summary 372 | ```{r} 373 | ggplot(gDat, aes(x = continent, y = lifeExp)) + 374 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 375 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 376 | 377 | ``` 378 | 379 | === 380 | Let's reorder the continent factor based on `lifeExp` 381 | ```{r} 382 | ggplot(gDat, aes(reorder(x = continent, lifeExp), y = lifeExp)) + 383 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 384 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 385 | 386 | ``` 387 | 388 | -------------------------------------------------------------------------------- /from_yair_goldberg/13-more-graphics.Rpres: -------------------------------------------------------------------------------- 1 | 4 | 5 | More Graphics 6 | ==== 7 | 8 | 9 | === 10 | 11 | The following presentation is based on the [ggplot2 tutorial](https://github.com/jennybc/ggplot2-tutorial) written by Prof. Jennifer Bryan. 12 | 13 | Load the library 14 | ```{r} 15 | library(ggplot2) 16 | ``` 17 | 18 | Read data 19 | ```{r} 20 | gdURL <- "http://tiny.cc/gapminder" 21 | gDat <- read.table(file = gdURL,header=T,sep = "\t") 22 | str(gDat) 23 | ``` 24 | 25 | 26 | 27 | Bar charts 28 | === 29 | 30 | Consider: number of observations for each continent 31 | 32 | ```{r} 33 | table(gDat$continent) 34 | 35 | ``` 36 | 37 | This works because default stat for `geom_bar()` is "bin" 38 | ```{r} 39 | ggplot(gDat, aes(x = continent)) + geom_bar() 40 | 41 | ``` 42 | 43 | Bar charts 44 | === 45 | Let's reorder the continents based on frequency 46 | ```{r} 47 | p <- ggplot(gDat, aes(x = reorder(continent, continent, length))) 48 | p + geom_bar() 49 | 50 | ``` 51 | 52 | 53 | Bar charts 54 | === 55 | Would you rather the bars run horizontally? 56 | ```{r} 57 | p + geom_bar() + coord_flip() 58 | 59 | ``` 60 | 61 | 62 | Bar charts 63 | === 64 | How about a better data:ink ratio? 65 | ```{r} 66 | p + geom_bar(width = 0.05) + coord_flip() 67 | 68 | ``` 69 | 70 | 71 | === 72 | Consider a scenario where you DON'T want the default "bin" stat, i.e. the bar length or height already exists as a variable 73 | ```{r} 74 | (jDat <- as.data.frame(with(gDat, table(continent, deparse.level = 2)))) 75 | 76 | ``` 77 | 78 | === 79 | 80 | This simple call no longer works, because we have pre-tabulated 81 | ```{r} 82 | ggplot(jDat, aes(x = continent)) + geom_bar() 83 | 84 | ``` 85 | 86 | === 87 | THIS works when bar length or height already exists 88 | 89 | ```{r} 90 | ggplot(jDat, aes(x = continent, y = Freq)) + geom_bar(stat = "identity") 91 | 92 | ``` 93 | 94 | 95 | 96 | Themes 97 | === 98 | 99 | The appearance of non-data elements of the plot is controlled by the theme system 100 | ```{r} 101 | library(ggthemes) 102 | ``` 103 | 104 | Themes 105 | === 106 | Revisit a plot from earlier 107 | ```{r} 108 | p <- ggplot(gDat, aes(x = gdpPercap, y = lifeExp)) 109 | p <- p + scale_x_log10() 110 | p <- p + aes(color = continent) + geom_point() + geom_smooth(lwd = 3, se = FALSE) 111 | p 112 | 113 | ``` 114 | 115 | Titles 116 | === 117 | Give it a title 118 | ```{r} 119 | p + ggtitle("Life expectancy over time by continent") 120 | 121 | ``` 122 | 123 | Themes 124 | === 125 | Change overall look and feel with a premade theme 126 | ```{r} 127 | p + theme_grey() # the default 128 | 129 | ``` 130 | 131 | Themes 132 | === 133 | Suppress the usual grey background 134 | ```{r} 135 | p + theme_bw() 136 | 137 | ``` 138 | 139 | Themes 140 | === 141 | Exploring some themes from the [ggthemes package]("https://github.com/jrnold/ggthemes") 142 | 143 | ```{r} 144 | p + theme_calc() + ggtitle("ggthemes::theme_calc()") 145 | 146 | ``` 147 | 148 | Themes 149 | === 150 | ```{r} 151 | p + theme_economist() + ggtitle("ggthemes::theme_economist()") 152 | 153 | ``` 154 | 155 | Themes 156 | === 157 | ```{r} 158 | p + theme_economist_white() + ggtitle("ggthemes::theme_economist_white()") 159 | 160 | ``` 161 | 162 | Themes 163 | === 164 | ```{r} 165 | p + theme_few() + ggtitle("ggthemes::theme_few()") 166 | 167 | ``` 168 | 169 | 170 | Themes 171 | === 172 | ```{r} 173 | p + theme_gdocs() + ggtitle("ggthemes::theme_gdocs()") 174 | 175 | ``` 176 | 177 | Themes 178 | === 179 | ```{r} 180 | p + theme_tufte() + ggtitle("ggthemes::theme_tufte()") 181 | 182 | ``` 183 | 184 | Themes 185 | === 186 | ```{r} 187 | p + theme_wsj() + ggtitle("ggthemes::theme_wsj()") 188 | 189 | ``` 190 | 191 | 192 | Colors 193 | === 194 | Let just look at four countries 195 | 196 | ```{r} 197 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 198 | x <- droplevels(subset(gDat, country %in% jCountries)) 199 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 200 | geom_line() + geom_point() 201 | 202 | ``` 203 | 204 | Colors 205 | === 206 | Reorder the country factor to reflect `lifeExp` in 2007 207 | ```{r} 208 | x <- transform(x, country = reorder(country, -1 * lifeExp, max)) 209 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 210 | geom_line() + geom_point() 211 | 212 | ``` 213 | 214 | Colors 215 | === 216 | Look at the RColorBrewer color palettes 217 | ```{r} 218 | library("RColorBrewer") 219 | display.brewer.all() 220 | 221 | ``` 222 | Colors 223 | === 224 | Focus on the qualitative palettes 225 | ```{r} 226 | display.brewer.all(type = "qual") 227 | 228 | ``` 229 | 230 | Colors 231 | === 232 | Pick some colors 233 | ```{r} 234 | #' pick some colors 235 | jColors = brewer.pal(n = 8, "Dark2")[seq_len(nlevels(x$country))] 236 | names(jColors) <- levels(x$country) 237 | ``` 238 | 239 | Colors 240 | === 241 | Remake the plot with our new colors 242 | ```{r} 243 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 244 | geom_line() + geom_point() + 245 | scale_color_manual(values = jColors) 246 | 247 | ``` 248 | 249 | Colors 250 | === 251 | Pick some super ugly colors for shock value 252 | ```{r} 253 | kColors = c("darkorange2", "deeppink3", "lawngreen", "peachpuff4") 254 | names(kColors) <- levels(x$country) 255 | 256 | ``` 257 | 258 | 259 | Remake the plot with our ugly colors 260 | ```{r} 261 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 262 | geom_line() + geom_point() + 263 | scale_color_manual(values = kColors) 264 | 265 | ``` 266 | 267 | === 268 | Load the color scheme 269 | 270 | 271 | ```{r} 272 | country_colors <- read.delim("gapminder-country-colors.tsv", 273 | colClasses = list(color = "character")) 274 | str(country_colors) 275 | ``` 276 | 277 | 278 | 279 | === 280 | Drop Oceania 281 | 282 | 283 | ```{r} 284 | gDat <- droplevels(subset(gDat, continent != "Oceania")) 285 | country_colors <- droplevels(subset(country_colors, continent != "Oceania")) 286 | 287 | jYear <- 2007 # this can obviously be changed 288 | jPch <- 21 289 | jDarkGray <- 'grey20' 290 | jXlim <- c(150, 115000) 291 | jYlim <- c(16, 100) 292 | ``` 293 | 294 | === 295 | Handy for ggplot2 `scale_fill_manual()` 296 | 297 | ```{r} 298 | jColors <- country_colors$color 299 | names(jColors) <- country_colors$country 300 | 301 | ggplot(subset(gDat, year == jYear), 302 | aes(x = gdpPercap, y = lifeExp)) + 303 | scale_x_log10(limits = jXlim) + ylim(jYlim) + 304 | geom_point(aes(size = sqrt(pop/pi)), pch = jPch, color = jDarkGray, 305 | show_guide = FALSE) + 306 | scale_size_continuous(range=c(1,40)) + 307 | facet_wrap(~ continent) + coord_fixed(ratio = 1/43) + 308 | aes(fill = country) + scale_fill_manual(values = jColors) + 309 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 310 | ``` 311 | 312 | 313 | 314 | 315 | -------------------------------------------------------------------------------- /gapminder-continent-colors.tsv: -------------------------------------------------------------------------------- 1 | continent country color 2 | Africa 52 #7F3B08 3 | Americas 25 #A50026 4 | Asia 33 #40004B 5 | Europe 30 #276419 6 | Oceania 2 #313695 7 | -------------------------------------------------------------------------------- /gapminder-country-colors.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/gapminder-country-colors.pdf -------------------------------------------------------------------------------- /gapminder-country-colors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/gapminder-country-colors.png -------------------------------------------------------------------------------- /gapminder-country-colors.tsv: -------------------------------------------------------------------------------- 1 | continent country color 2 | Africa Nigeria #7F3B08 3 | Africa Egypt #833D07 4 | Africa Ethiopia #873F07 5 | Africa South Africa #8B4107 6 | Africa Congo, Dem. Rep. #8F4407 7 | Africa Morocco #934607 8 | Africa Algeria #974807 9 | Africa Sudan #9B4A06 10 | Africa Tanzania #9F4D06 11 | Africa Kenya #A34F06 12 | Africa Mozambique #A75106 13 | Africa Uganda #AB5406 14 | Africa Ghana #AF5606 15 | Africa Cameroon #B35806 16 | Africa Madagascar #B75C07 17 | Africa Burkina Faso #BA5F08 18 | Africa Angola #BE6209 19 | Africa Mali #C2650A 20 | Africa Tunisia #C5690B 21 | Africa Niger #C96C0C 22 | Africa Zimbabwe #CC6F0D 23 | Africa Cote d'Ivoire #D0730F 24 | Africa Malawi #D37610 25 | Africa Senegal #D77911 26 | Africa Chad #DA7D12 27 | Africa Zambia #DE8013 28 | Africa Guinea #E18417 29 | Africa Rwanda #E3881D 30 | Africa Somalia #E58C23 31 | Africa Burundi #E79029 32 | Africa Sierra Leone #EA952F 33 | Africa Benin #EC9936 34 | Africa Eritrea #EE9D3C 35 | Africa Central African Republic #F1A142 36 | Africa Togo #F3A548 37 | Africa Mauritania #F5AA4E 38 | Africa Libya #F7AE55 39 | Africa Liberia #FAB25B 40 | Africa Congo, Rep. #FCB661 41 | Africa Lesotho #FDBA67 42 | Africa Guinea-Bissau #FDBD6E 43 | Africa Mauritius #FDC074 44 | Africa Namibia #FDC37B 45 | Africa Botswana #FDC681 46 | Africa Gabon #FDCA88 47 | Africa Swaziland #FDCD8E 48 | Africa Gambia #FDD095 49 | Africa Reunion #FDD39B 50 | Africa Equatorial Guinea #FDD6A2 51 | Africa Comoros #FDD9A8 52 | Africa Djibouti #FDDCAF 53 | Africa Sao Tome and Principe #FEE0B6 54 | Americas United States #A50026 55 | Americas Brazil #AD0826 56 | Americas Mexico #B51026 57 | Americas Argentina #BE1826 58 | Americas Canada #C62026 59 | Americas Colombia #CE2726 60 | Americas Peru #D73027 61 | Americas Chile #DB3A2B 62 | Americas Cuba #E04430 63 | Americas Venezuela #E54E35 64 | Americas Ecuador #EA5839 65 | Americas Haiti #EF623E 66 | Americas Guatemala #F46D43 67 | Americas Bolivia #F57748 68 | Americas Dominican Republic #F7824D 69 | Americas Uruguay #F88D51 70 | Americas Puerto Rico #FA9856 71 | Americas El Salvador #FBA35B 72 | Americas Paraguay #FDAE61 73 | Americas Honduras #FDB668 74 | Americas Jamaica #FDBE70 75 | Americas Nicaragua #FDC778 76 | Americas Panama #FDCF80 77 | Americas Costa Rica #FDD788 78 | Americas Trinidad and Tobago #FEE090 79 | Asia China #40004B 80 | Asia India #460552 81 | Asia Japan #4D0A59 82 | Asia Indonesia #540F60 83 | Asia Bangladesh #5B1567 84 | Asia Pakistan #611A6D 85 | Asia Vietnam #681F75 86 | Asia Philippines #6F247B 87 | Asia Thailand #762A83 88 | Asia Korea, Rep. #7A3288 89 | Asia Myanmar #7E3B8C 90 | Asia Iran #834492 91 | Asia Nepal #874D96 92 | Asia Korea, Dem. Rep. #8B559B 93 | Asia Taiwan #905EA1 94 | Asia Afghanistan #9467A5 95 | Asia Sri Lanka #9970AB 96 | Asia Malaysia #9E76AF 97 | Asia Iraq #A37DB3 98 | Asia Yemen, Rep. #A883B8 99 | Asia Cambodia #AD8ABD 100 | Asia Saudi Arabia #B291C1 101 | Asia Syria #B797C6 102 | Asia Hong Kong, China #BC9ECA 103 | Asia Israel #C2A5CF 104 | Asia Lebanon #C6AAD2 105 | Asia Singapore #CBB0D5 106 | Asia West Bank and Gaza #CFB6D8 107 | Asia Mongolia #D4BCDB 108 | Asia Jordan #D9C2DE 109 | Asia Oman #DDC8E1 110 | Asia Kuwait #E2CEE4 111 | Asia Bahrain #E7D4E8 112 | Europe Germany #276419 113 | Europe United Kingdom #2C6A1A 114 | Europe Italy #31701B 115 | Europe France #36771C 116 | Europe Spain #3B7D1D 117 | Europe Poland #41831E 118 | Europe Turkey #468A1F 119 | Europe Romania #4B9020 120 | Europe Netherlands #529624 121 | Europe Hungary #599C28 122 | Europe Czech Republic #5FA12D 123 | Europe Belgium #66A731 124 | Europe Portugal #6DAD35 125 | Europe Greece #74B33A 126 | Europe Bulgaria #7BB93E 127 | Europe Sweden #82BE45 128 | Europe Austria #8AC34F 129 | Europe Serbia #92C858 130 | Europe Switzerland #9ACD62 131 | Europe Denmark #A2D26B 132 | Europe Finland #AAD875 133 | Europe Croatia #B2DD7E 134 | Europe Slovak Republic #B9E188 135 | Europe Norway #BFE492 136 | Europe Ireland #C6E79C 137 | Europe Bosnia and Herzegovina #CCE9A7 138 | Europe Slovenia #D2ECB1 139 | Europe Albania #D9EFBB 140 | Europe Montenegro #DFF2C5 141 | Europe Iceland #E6F5D0 142 | Oceania Australia #313695 143 | Oceania New Zealand #4575B4 144 | -------------------------------------------------------------------------------- /gapminder-gganimate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/gapminder-gganimate.gif -------------------------------------------------------------------------------- /gapminder-gganimate.rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Animate the Gapminder data set using gganimate" 3 | author: "Shaun Jackman" 4 | date: "2017-10-19" 5 | --- 6 | 7 | Inspired by Hans Rosling's TED Talk: 8 | [The best stats you've ever seen](https://www.ted.com/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen). 9 | 10 | The code is taken nearly verbatim from the [gganimate example](https://github.com/dgrtwo/gganimate#gganimate-create-easy-animations-with-ggplot2). 11 | 12 | # Install packages 13 | 14 | ```{r install-packages, eval=FALSE} 15 | install.packages(c("devtools", "dplyr", "ggplot2", "readr")) 16 | library(devtools) 17 | devtools::install_github("dgrtwo/gganimate") 18 | ``` 19 | 20 | Note that [gganimate](https://github.com/dgrtwo/gganimate) requires [ImageMagick](http://www.imagemagick.org/script/index.php). To install it, use [Homebrew](http://brew.sh) on a Mac and [Linuxbrew](http://linuxbrew.sh) or `apt-get` or `yum` on Linux: 21 | 22 | ```sh 23 | brew install imagemagick 24 | sudo apt-get install imagemagick 25 | sudo yum install imagemagick 26 | ``` 27 | 28 | # Load packages 29 | 30 | ```{r setup, message=FALSE} 31 | library(dplyr) 32 | library(gganimate) 33 | library(ggplot2) 34 | library(readr) 35 | ``` 36 | 37 | # Read the Gapminder data 38 | 39 | ```{r read-gapminder-data} 40 | gapminder <- read_tsv("gapminderDataFiveYear.tsv") 41 | glimpse(gapminder) 42 | ``` 43 | 44 | # Plot the Gapminder data 45 | 46 | ```{r plot-gapminder-data} 47 | gapminder_plot <- ggplot(gapminder) + 48 | aes(x = gdpPercap, y = lifeExp, colour = continent, size = pop, 49 | frame = year) + 50 | geom_point(alpha = 0.4) + 51 | scale_x_log10() 52 | gapminder_plot 53 | ``` 54 | 55 | # Animate the Gapminder data 56 | 57 | ```{r animate-gapminder-data, message=FALSE} 58 | gganimate(gapminder_plot, filename = "gapminder-gganimate.gif") 59 | ``` 60 | 61 | ![Animated Gapminder figure](gapminder-gganimate.gif) 62 | -------------------------------------------------------------------------------- /gapminder-ggplot2-colors.md: -------------------------------------------------------------------------------- 1 | Jenny Bryan 2 | 3 | 4 | 5 | Note: this HTML is made by applying `knitr::spin()` to an R script. So the 6 | narrative is very minimal. 7 | 8 | 9 | ```r 10 | library(ggplot2) 11 | library(RColorBrewer) 12 | ``` 13 | 14 | pick a way to load the data 15 | 16 | 17 | ```r 18 | #gdURL <- "http://tiny.cc/gapminder" 19 | #gapminder <- read.delim(file = gdURL) 20 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 21 | library(gapminder) 22 | str(gapminder) 23 | ``` 24 | 25 | ``` 26 | ## 'data.frame': 1704 obs. of 6 variables: 27 | ## $ country : Factor w/ 142 levels "Afghanistan",..: 1 1 1 1 1 1 1 1 1 1 ... 28 | ## $ continent: Factor w/ 5 levels "Africa","Americas",..: 3 3 3 3 3 3 3 3 3 3 ... 29 | ## $ year : num 1952 1957 1962 1967 1972 ... 30 | ## $ lifeExp : num 28.8 30.3 32 34 36.1 ... 31 | ## $ pop : num 8425333 9240934 10267083 11537966 13079460 ... 32 | ## $ gdpPercap: num 779 821 853 836 740 ... 33 | ``` 34 | 35 | let just look at four countries 36 | 37 | 38 | ```r 39 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 40 | x <- droplevels(subset(gapminder, country %in% jCountries)) 41 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 42 | geom_line() + geom_point() 43 | ``` 44 | 45 | ![](figure/colors-unnamed-chunk-3-1.png) 46 | 47 | reorder the country factor to reflect lifeExp in 2007 48 | 49 | 50 | ```r 51 | x <- transform(x, country = reorder(country, -1 * lifeExp, max)) 52 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 53 | geom_line() + geom_point() 54 | ``` 55 | 56 | ![](figure/colors-unnamed-chunk-4-1.png) 57 | 58 | look at the RColorBrewer color palettes 59 | 60 | 61 | ```r 62 | display.brewer.all() 63 | ``` 64 | 65 | ![](figure/colors-unnamed-chunk-5-1.png) 66 | 67 | focus on the qualitative palettes 68 | 69 | 70 | ```r 71 | display.brewer.all(type = "qual") 72 | ``` 73 | 74 | ![](figure/colors-unnamed-chunk-6-1.png) 75 | 76 | pick some colors 77 | 78 | 79 | ```r 80 | jColors = brewer.pal(n = 8, "Dark2")[seq_len(nlevels(x$country))] 81 | names(jColors) <- levels(x$country) 82 | ``` 83 | 84 | remake the plot with our new colors 85 | 86 | 87 | ```r 88 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 89 | geom_line() + geom_point() + 90 | scale_color_manual(values = jColors) 91 | ``` 92 | 93 | ![](figure/colors-unnamed-chunk-8-1.png) 94 | 95 | pick some super ugly colors for shock value 96 | 97 | 98 | ```r 99 | kColors = c("darkorange2", "deeppink3", "lawngreen", "peachpuff4") 100 | names(kColors) <- levels(x$country) 101 | ``` 102 | 103 | remake the plot with our ugly colors 104 | 105 | 106 | ```r 107 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 108 | geom_line() + geom_point() + 109 | scale_color_manual(values = kColors) 110 | ``` 111 | 112 | ![](figure/colors-unnamed-chunk-10-1.png) 113 | 114 | ```r 115 | sessionInfo() 116 | ``` 117 | 118 | ``` 119 | ## R version 3.1.2 (2014-10-31) 120 | ## Platform: x86_64-apple-darwin10.8.0 (64-bit) 121 | ## 122 | ## locale: 123 | ## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 124 | ## 125 | ## attached base packages: 126 | ## [1] stats graphics grDevices utils datasets methods base 127 | ## 128 | ## other attached packages: 129 | ## [1] gapminder_0.1.0 RColorBrewer_1.0-5 ggplot2_1.0.0 130 | ## [4] knitr_1.10.5 131 | ## 132 | ## loaded via a namespace (and not attached): 133 | ## [1] colorspace_1.2-4 digest_0.6.8 evaluate_0.7 134 | ## [4] formatR_1.2 grid_3.1.2 gtable_0.1.2 135 | ## [7] htmltools_0.2.6 labeling_0.3 magrittr_1.5 136 | ## [10] MASS_7.3-35 munsell_0.4.2 plyr_1.8.2 137 | ## [13] proto_0.3-10 Rcpp_0.11.6 reshape2_1.4.0.99 138 | ## [16] rmarkdown_0.5.1 scales_0.2.4 stringi_0.4-1 139 | ## [19] stringr_1.0.0 tools_3.1.2 yaml_2.1.13 140 | ``` 141 | 142 | 143 | --- 144 | title: "gapminder-ggplot2-colors.r" 145 | author: "jenny" 146 | date: "Thu May 14 12:58:27 2015" 147 | --- 148 | -------------------------------------------------------------------------------- /gapminder-ggplot2-colors.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: 4 | #' html_document: 5 | #' keep_md: TRUE 6 | #' --- 7 | 8 | #+ setup, include = FALSE 9 | library(knitr) 10 | opts_chunk$set(fig.path = 'figure/colors-', error = TRUE) 11 | 12 | #' Note: this HTML is made by applying `knitr::spin()` to an R script. So the 13 | #' narrative is very minimal. 14 | 15 | library(ggplot2) 16 | library(RColorBrewer) 17 | 18 | #' pick a way to load the data 19 | #gdURL <- "http://tiny.cc/gapminder" 20 | #gapminder <- read.delim(file = gdURL) 21 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 22 | library(gapminder) 23 | str(gapminder) 24 | 25 | #' let just look at four countries 26 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 27 | x <- droplevels(subset(gapminder, country %in% jCountries)) 28 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 29 | geom_line() + geom_point() 30 | 31 | #' reorder the country factor to reflect lifeExp in 2007 32 | x <- transform(x, country = reorder(country, -1 * lifeExp, max)) 33 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 34 | geom_line() + geom_point() 35 | 36 | #' look at the RColorBrewer color palettes 37 | display.brewer.all() 38 | 39 | #' focus on the qualitative palettes 40 | display.brewer.all(type = "qual") 41 | 42 | #' pick some colors 43 | jColors = brewer.pal(n = 8, "Dark2")[seq_len(nlevels(x$country))] 44 | names(jColors) <- levels(x$country) 45 | 46 | #' remake the plot with our new colors 47 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 48 | geom_line() + geom_point() + 49 | scale_color_manual(values = jColors) 50 | 51 | #' pick some super ugly colors for shock value 52 | kColors = c("darkorange2", "deeppink3", "lawngreen", "peachpuff4") 53 | names(kColors) <- levels(x$country) 54 | 55 | #' remake the plot with our ugly colors 56 | ggplot(x, aes(x = year, y = lifeExp, color = country)) + 57 | geom_line() + geom_point() + 58 | scale_color_manual(values = kColors) 59 | 60 | sessionInfo() -------------------------------------------------------------------------------- /gapminder-ggplot2-scatterplot.md: -------------------------------------------------------------------------------- 1 | gapminder-ggplot2-scatterplot.r 2 | ================ 3 | Jenny Bryan 4 | Mon Oct 3 23:50:31 2016 5 | 6 | Note: this report is made by rendering an R script. So the narrative is very minimal. 7 | 8 | ``` r 9 | library(tibble) 10 | library(ggplot2) 11 | ``` 12 | 13 | Load the [`gapminder`](https://github.com/jennybc/gapminder) data package. 14 | 15 | ``` r 16 | library(gapminder) 17 | gapminder 18 | ``` 19 | 20 | ## # A tibble: 1,704 × 6 21 | ## country continent year lifeExp pop gdpPercap 22 | ## 23 | ## 1 Afghanistan Asia 1952 28.801 8425333 779.4453 24 | ## 2 Afghanistan Asia 1957 30.332 9240934 820.8530 25 | ## 3 Afghanistan Asia 1962 31.997 10267083 853.1007 26 | ## 4 Afghanistan Asia 1967 34.020 11537966 836.1971 27 | ## 5 Afghanistan Asia 1972 36.088 13079460 739.9811 28 | ## 6 Afghanistan Asia 1977 38.438 14880372 786.1134 29 | ## 7 Afghanistan Asia 1982 39.854 12881816 978.0114 30 | ## 8 Afghanistan Asia 1987 40.822 13867957 852.3959 31 | ## 9 Afghanistan Asia 1992 41.674 16317921 649.3414 32 | ## 10 Afghanistan Asia 1997 41.763 22227415 635.3414 33 | ## # ... with 1,694 more rows 34 | 35 | ``` r 36 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) # nothing to plot yet! 37 | ``` 38 | 39 | ![](figure/scatterplot-unnamed-chunk-2-1.png) 40 | 41 | ``` r 42 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 43 | geom_point() 44 | ``` 45 | 46 | ![](figure/scatterplot-unnamed-chunk-2-2.png) 47 | 48 | ``` r 49 | p <- ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) # just initializes 50 | ``` 51 | 52 | scatterplot 53 | 54 | ``` r 55 | p + geom_point() 56 | ``` 57 | 58 | ![](figure/scatterplot-unnamed-chunk-3-1.png) 59 | 60 | log transformation ... quick and dirty 61 | 62 | ``` r 63 | ggplot(gapminder, aes(x = log10(gdpPercap), y = lifeExp)) + 64 | geom_point() 65 | ``` 66 | 67 | ![](figure/scatterplot-unnamed-chunk-4-1.png) 68 | 69 | a better way to log transform 70 | 71 | ``` r 72 | p + geom_point() + scale_x_log10() 73 | ``` 74 | 75 | ![](figure/scatterplot-unnamed-chunk-5-1.png) 76 | 77 | let's make that stick 78 | 79 | ``` r 80 | p <- p + scale_x_log10() 81 | ``` 82 | 83 | common workflow: gradually build up the plot you want 84 | re-define the object 'p' as you develop "keeper" commands 85 | convey continent by color: MAP continent variable to aesthetic color 86 | 87 | ``` r 88 | p + geom_point(aes(color = continent)) 89 | ``` 90 | 91 | ![](figure/scatterplot-unnamed-chunk-7-1.png) 92 | 93 | ``` r 94 | ## add summary(p)! 95 | plot(gapminder, aes(x = gdpPercap, y = lifeExp, color = continent)) + 96 | geom_point() + scale_x_log10() # in full detail, up to now 97 | ``` 98 | 99 | ## Error in plot(gapminder, aes(x = gdpPercap, y = lifeExp, color = continent)) + : non-numeric argument to binary operator 100 | 101 | ![](figure/scatterplot-unnamed-chunk-7-2.png) 102 | 103 | address overplotting: SET alpha transparency and size to a value 104 | 105 | ``` r 106 | p + geom_point(alpha = (1/3), size = 3) 107 | ``` 108 | 109 | ![](figure/scatterplot-unnamed-chunk-8-1.png) 110 | 111 | add a fitted curve or line 112 | 113 | ``` r 114 | p + geom_point() + geom_smooth() 115 | ``` 116 | 117 | ![](figure/scatterplot-unnamed-chunk-9-1.png) 118 | 119 | ``` r 120 | p + geom_point() + geom_smooth(lwd = 3, se = FALSE) 121 | ``` 122 | 123 | ![](figure/scatterplot-unnamed-chunk-9-2.png) 124 | 125 | ``` r 126 | p + geom_point() + geom_smooth(lwd = 3, se = FALSE, method = "lm") 127 | ``` 128 | 129 | ![](figure/scatterplot-unnamed-chunk-9-3.png) 130 | 131 | revive our interest in continents! 132 | 133 | ``` r 134 | p + aes(color = continent) + geom_point() + 135 | geom_smooth(lwd = 3, se = FALSE) 136 | ``` 137 | 138 | ![](figure/scatterplot-unnamed-chunk-10-1.png) 139 | 140 | facetting: another way to exploit a factor 141 | 142 | ``` r 143 | p + geom_point(alpha = (1/3), size = 3) + 144 | facet_wrap(~ continent) 145 | ``` 146 | 147 | ![](figure/scatterplot-unnamed-chunk-11-1.png) 148 | 149 | ``` r 150 | p + geom_point(alpha = (1/3), size = 3) + 151 | facet_wrap(~ continent) + 152 | geom_smooth(lwd = 2, se = FALSE) 153 | ``` 154 | 155 | ![](figure/scatterplot-unnamed-chunk-11-2.png) 156 | 157 | exercises: 158 | \* plot lifeExp against year 159 | 160 | ``` r 161 | ggplot(gapminder, aes(x = year, y = lifeExp, 162 | color = continent)) + 163 | geom_jitter(alpha = 1/3, size = 3) 164 | ``` 165 | 166 | ![](figure/scatterplot-unnamed-chunk-12-1.png) 167 | 168 | - make mini-plots, split out by continent HINT: use facet\_wrap() 169 | 170 | ``` r 171 | ggplot(gapminder, aes(x = year, y = lifeExp, 172 | color = continent)) + 173 | facet_wrap(~ continent, scales = "free_x") + 174 | geom_jitter(alpha = 1/3, size = 3) + 175 | scale_color_manual(values = continent_colors) 176 | ``` 177 | 178 | ![](figure/scatterplot-unnamed-chunk-13-1.png) 179 | 180 | ``` r 181 | ggplot(subset(gapminder, continent != "Oceania"), 182 | aes(x = year, y = lifeExp, group = country, color = country)) + 183 | geom_line(lwd = 1, show_guide = FALSE) + facet_wrap(~ continent) + 184 | scale_color_manual(values = country_colors) + 185 | #scale_color_brewer()+ 186 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 187 | ``` 188 | 189 | ## Warning: `show_guide` has been deprecated. Please use `show.legend` 190 | ## instead. 191 | 192 | ![](figure/scatterplot-unnamed-chunk-13-2.png) 193 | 194 | - add a fitted smooth and/or linear regression, w/ or w/o facetting 195 | 196 | ``` r 197 | ggplot(gapminder, aes(x = year, y = lifeExp, 198 | color = continent)) + 199 | facet_wrap(~ continent, scales = "free_x") + 200 | geom_jitter(alpha = 1/3, size = 3) + 201 | scale_color_manual(values = continent_colors) + 202 | geom_smooth(lwd = 2) 203 | ``` 204 | 205 | ![](figure/scatterplot-unnamed-chunk-14-1.png) 206 | 207 | - use `dplyr::filter()` to plot lifeExp against year for just one country or continent 208 | 209 | ``` r 210 | jc <- "Cambodia" 211 | gapminder %>% 212 | filter(country == jc) %>% 213 | ggplot(aes(x = year, y = lifeExp)) + 214 | labs(title = jc) + 215 | geom_line() 216 | ``` 217 | 218 | ## Error in eval(expr, envir, enclos): could not find function "%>%" 219 | 220 | ``` r 221 | rwanda <- gapminder %>% 222 | filter(country == "Rwanda") 223 | ``` 224 | 225 | ## Error in eval(expr, envir, enclos): could not find function "%>%" 226 | 227 | ``` r 228 | p <- ggplot(rwanda, aes(x = year, y = lifeExp)) + 229 | labs(title = "Rwanda") + 230 | geom_line() 231 | ``` 232 | 233 | ## Error in ggplot(rwanda, aes(x = year, y = lifeExp)): object 'rwanda' not found 234 | 235 | ``` r 236 | print(p) 237 | ``` 238 | 239 | ![](figure/scatterplot-unnamed-chunk-15-1.png) 240 | 241 | ``` r 242 | ggsave("rwanda.pdf") 243 | ``` 244 | 245 | ## Saving 7 x 5 in image 246 | 247 | ``` r 248 | ggsave("rwanda.pdf",plot = p) 249 | ``` 250 | 251 | ## Saving 7 x 5 in image 252 | 253 | - other ideas? 254 | plot lifeExp against year 255 | 256 | ``` r 257 | (y <- ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_point()) 258 | ``` 259 | 260 | ![](figure/scatterplot-unnamed-chunk-16-1.png) 261 | 262 | make mini-plots, split out by continent 263 | 264 | ``` r 265 | y + facet_wrap(~ continent) 266 | ``` 267 | 268 | ![](figure/scatterplot-unnamed-chunk-17-1.png) 269 | 270 | add a fitted smooth and/or linear regression, w/ or w/o facetting 271 | 272 | ``` r 273 | y + geom_smooth(se = FALSE, lwd = 2) + 274 | geom_smooth(se = FALSE, method ="lm", color = "orange", lwd = 2) 275 | ``` 276 | 277 | ![](figure/scatterplot-unnamed-chunk-18-1.png) 278 | 279 | ``` r 280 | y + geom_smooth(se = FALSE, lwd = 2) + 281 | facet_wrap(~ continent) 282 | ``` 283 | 284 | ![](figure/scatterplot-unnamed-chunk-18-2.png) 285 | 286 | last bit on scatterplots 287 | how can we "connect the dots" for one country? 288 | i.e. make a spaghetti plot? 289 | 290 | ``` r 291 | y + facet_wrap(~ continent) + geom_line() # uh, no 292 | ``` 293 | 294 | ![](figure/scatterplot-unnamed-chunk-19-1.png) 295 | 296 | ``` r 297 | y + facet_wrap(~ continent) + geom_line(aes(group = country)) # yes! 298 | ``` 299 | 300 | ![](figure/scatterplot-unnamed-chunk-19-2.png) 301 | 302 | ``` r 303 | y + facet_wrap(~ continent) + geom_line(aes(group = country)) + 304 | geom_smooth(se = FALSE, lwd = 2) 305 | ``` 306 | 307 | ![](figure/scatterplot-unnamed-chunk-19-3.png) 308 | 309 | note about subsetting data sadly, ggplot() does not have a 'subset =' argument 310 | so do that 'on the fly' with subset(..., subset = ...) 311 | 312 | ``` r 313 | ggplot(subset(gapminder, country == "Zimbabwe"), 314 | aes(x = year, y = lifeExp)) + geom_line() + geom_point() 315 | ``` 316 | 317 | ![](figure/scatterplot-unnamed-chunk-20-1.png) 318 | 319 | or could do with dplyr::filter 320 | 321 | ``` r 322 | suppressPackageStartupMessages(library(dplyr)) 323 | ggplot(gapminder %>% filter(country == "Zimbabwe"), 324 | aes(x = year, y = lifeExp)) + geom_line() + geom_point() 325 | ``` 326 | 327 | ![](figure/scatterplot-unnamed-chunk-21-1.png) 328 | 329 | let just look at four countries 330 | 331 | ``` r 332 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 333 | ggplot(subset(gapminder, country %in% jCountries), 334 | aes(x = year, y = lifeExp, color = country)) + geom_line() + geom_point() 335 | ``` 336 | 337 | ![](figure/scatterplot-unnamed-chunk-22-1.png) 338 | 339 | when you really care, make your legend easy to navigate 340 | this means visual order = data order = factor level order 341 | 342 | ``` r 343 | ggplot(subset(gapminder, country %in% jCountries), 344 | aes(x = year, y = lifeExp, color = reorder(country, -1 * lifeExp, max))) + 345 | geom_line() + geom_point() 346 | ``` 347 | 348 | ![](figure/scatterplot-unnamed-chunk-23-1.png) 349 | 350 | another approach to overplotting ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 351 | 352 | ``` r 353 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 354 | scale_x_log10() + geom_bin2d() 355 | ``` 356 | 357 | ![](figure/scatterplot-unnamed-chunk-24-1.png) 358 | 359 | ``` r 360 | sessionInfo() 361 | ``` 362 | 363 | ## R version 3.3.1 (2016-06-21) 364 | ## Platform: x86_64-apple-darwin13.4.0 (64-bit) 365 | ## Running under: OS X 10.11.6 (El Capitan) 366 | ## 367 | ## locale: 368 | ## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 369 | ## 370 | ## attached base packages: 371 | ## [1] stats graphics grDevices utils datasets methods base 372 | ## 373 | ## other attached packages: 374 | ## [1] dplyr_0.5.0 gapminder_0.2.0 ggplot2_2.1.0 tibble_1.2 375 | ## [5] knitr_1.14.2 376 | ## 377 | ## loaded via a namespace (and not attached): 378 | ## [1] Rcpp_0.12.7 magrittr_1.5 munsell_0.4.3 379 | ## [4] colorspace_1.2-6 lattice_0.20-33 R6_2.1.3 380 | ## [7] stringr_1.1.0 plyr_1.8.4 tools_3.3.1 381 | ## [10] grid_3.3.1 gtable_0.2.0 nlme_3.1-128 382 | ## [13] mgcv_1.8-13 DBI_0.4-1 htmltools_0.3.5 383 | ## [16] lazyeval_0.2.0 yaml_2.1.13 assertthat_0.1 384 | ## [19] digest_0.6.10 Matrix_1.2-6 formatR_1.4 385 | ## [22] evaluate_0.9 rmarkdown_1.0.9014 labeling_0.3 386 | ## [25] stringi_1.1.1 scales_0.4.0 387 | -------------------------------------------------------------------------------- /gapminder-ggplot2-scatterplot.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: github_document 4 | #' --- 5 | 6 | #+ setup, include = FALSE 7 | library(knitr) 8 | opts_chunk$set(fig.path = 'figure/scatterplot-', error = TRUE) 9 | 10 | #' Note: this report is made by rendering an R script. So the narrative is very 11 | #' minimal. 12 | 13 | library(tibble) 14 | library(ggplot2) 15 | 16 | #' Load the [`gapminder`](https://github.com/jennybc/gapminder) data package. 17 | library(gapminder) 18 | gapminder 19 | 20 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) # nothing to plot yet! 21 | 22 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 23 | geom_point() 24 | 25 | p <- ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) # just initializes 26 | 27 | #' scatterplot 28 | p + geom_point() 29 | 30 | #' log transformation ... quick and dirty 31 | ggplot(gapminder, aes(x = log10(gdpPercap), y = lifeExp)) + 32 | geom_point() 33 | #' a better way to log transform 34 | p + geom_point() + scale_x_log10() 35 | 36 | #' let's make that stick 37 | p <- p + scale_x_log10() 38 | #' common workflow: gradually build up the plot you want 39 | #' re-define the object 'p' as you develop "keeper" commands 40 | 41 | #' convey continent by color: MAP continent variable to aesthetic color 42 | p + geom_point(aes(color = continent)) 43 | ## add summary(p)! 44 | plot(gapminder, aes(x = gdpPercap, y = lifeExp, color = continent)) + 45 | geom_point() + scale_x_log10() # in full detail, up to now 46 | 47 | #' address overplotting: SET alpha transparency and size to a value 48 | p + geom_point(alpha = (1/3), size = 3) 49 | 50 | #' add a fitted curve or line 51 | p + geom_point() + geom_smooth() 52 | p + geom_point() + geom_smooth(lwd = 3, se = FALSE) 53 | p + geom_point() + geom_smooth(lwd = 3, se = FALSE, method = "lm") 54 | 55 | #' revive our interest in continents! 56 | p + aes(color = continent) + geom_point() + 57 | geom_smooth(lwd = 3, se = FALSE) 58 | 59 | #' facetting: another way to exploit a factor 60 | p + geom_point(alpha = (1/3), size = 3) + 61 | facet_wrap(~ continent) 62 | p + geom_point(alpha = (1/3), size = 3) + 63 | facet_wrap(~ continent) + 64 | geom_smooth(lwd = 2, se = FALSE) 65 | 66 | #' exercises: 67 | 68 | #' * plot lifeExp against year 69 | ggplot(gapminder, aes(x = year, y = lifeExp, 70 | color = continent)) + 71 | geom_jitter(alpha = 1/3, size = 3) 72 | 73 | #' * make mini-plots, split out by continent 74 | #' HINT: use facet_wrap() 75 | ggplot(gapminder, aes(x = year, y = lifeExp, 76 | color = continent)) + 77 | facet_wrap(~ continent, scales = "free_x") + 78 | geom_jitter(alpha = 1/3, size = 3) + 79 | scale_color_manual(values = continent_colors) 80 | 81 | ggplot(subset(gapminder, continent != "Oceania"), 82 | aes(x = year, y = lifeExp, group = country, color = country)) + 83 | geom_line(lwd = 1, show_guide = FALSE) + facet_wrap(~ continent) + 84 | scale_color_manual(values = country_colors) + 85 | #scale_color_brewer()+ 86 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 87 | 88 | 89 | #' * add a fitted smooth and/or linear regression, w/ or w/o facetting 90 | 91 | ggplot(gapminder, aes(x = year, y = lifeExp, 92 | color = continent)) + 93 | facet_wrap(~ continent, scales = "free_x") + 94 | geom_jitter(alpha = 1/3, size = 3) + 95 | scale_color_manual(values = continent_colors) + 96 | geom_smooth(lwd = 2) 97 | 98 | 99 | #' * use `dplyr::filter()` to plot lifeExp against 100 | #' year for just one country or continent 101 | jc <- "Cambodia" 102 | gapminder %>% 103 | filter(country == jc) %>% 104 | ggplot(aes(x = year, y = lifeExp)) + 105 | labs(title = jc) + 106 | geom_line() 107 | 108 | rwanda <- gapminder %>% 109 | filter(country == "Rwanda") 110 | p <- ggplot(rwanda, aes(x = year, y = lifeExp)) + 111 | labs(title = "Rwanda") + 112 | geom_line() 113 | print(p) 114 | ggsave("rwanda.pdf") 115 | ggsave("rwanda.pdf",plot = p) 116 | 117 | #' * other ideas? 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | #' plot lifeExp against year 129 | (y <- ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_point()) 130 | 131 | #' make mini-plots, split out by continent 132 | y + facet_wrap(~ continent) 133 | 134 | #' add a fitted smooth and/or linear regression, w/ or w/o facetting 135 | y + geom_smooth(se = FALSE, lwd = 2) + 136 | geom_smooth(se = FALSE, method ="lm", color = "orange", lwd = 2) 137 | 138 | y + geom_smooth(se = FALSE, lwd = 2) + 139 | facet_wrap(~ continent) 140 | 141 | #' last bit on scatterplots 142 | #' how can we "connect the dots" for one country? 143 | #' i.e. make a spaghetti plot? 144 | y + facet_wrap(~ continent) + geom_line() # uh, no 145 | y + facet_wrap(~ continent) + geom_line(aes(group = country)) # yes! 146 | y + facet_wrap(~ continent) + geom_line(aes(group = country)) + 147 | geom_smooth(se = FALSE, lwd = 2) 148 | 149 | #' note about subsetting data 150 | 151 | #' sadly, ggplot() does not have a 'subset =' argument 152 | #' so do that 'on the fly' with subset(..., subset = ...) 153 | ggplot(subset(gapminder, country == "Zimbabwe"), 154 | aes(x = year, y = lifeExp)) + geom_line() + geom_point() 155 | 156 | #' or could do with dplyr::filter 157 | suppressPackageStartupMessages(library(dplyr)) 158 | ggplot(gapminder %>% filter(country == "Zimbabwe"), 159 | aes(x = year, y = lifeExp)) + geom_line() + geom_point() 160 | 161 | #' let just look at four countries 162 | jCountries <- c("Canada", "Rwanda", "Cambodia", "Mexico") 163 | ggplot(subset(gapminder, country %in% jCountries), 164 | aes(x = year, y = lifeExp, color = country)) + geom_line() + geom_point() 165 | 166 | #' when you really care, make your legend easy to navigate 167 | #' this means visual order = data order = factor level order 168 | ggplot(subset(gapminder, country %in% jCountries), 169 | aes(x = year, y = lifeExp, color = reorder(country, -1 * lifeExp, max))) + 170 | geom_line() + geom_point() 171 | 172 | #' another approach to overplotting 173 | #' ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 174 | ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) + 175 | scale_x_log10() + geom_bin2d() 176 | 177 | sessionInfo() -------------------------------------------------------------------------------- /gapminder-ggplot2-shock-and-awe.md: -------------------------------------------------------------------------------- 1 | Jenny Bryan 2 | 3 | 4 | 5 | Note: this HTML is made by applying `knitr::spin()` to an R script. So the 6 | narrative is very minimal. 7 | 8 | 9 | ```r 10 | library(ggplot2) 11 | ``` 12 | 13 | pick a way to load the data 14 | 15 | 16 | ```r 17 | #gdURL <- "http://tiny.cc/gapminder" 18 | #gapminder <- read.delim(file = gdURL) 19 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 20 | library(gapminder) 21 | str(gapminder) 22 | ``` 23 | 24 | ``` 25 | ## 'data.frame': 1704 obs. of 6 variables: 26 | ## $ country : Factor w/ 142 levels "Afghanistan",..: 1 1 1 1 1 1 1 1 1 1 ... 27 | ## $ continent: Factor w/ 5 levels "Africa","Americas",..: 3 3 3 3 3 3 3 3 3 3 ... 28 | ## $ year : num 1952 1957 1962 1967 1972 ... 29 | ## $ lifeExp : num 28.8 30.3 32 34 36.1 ... 30 | ## $ pop : num 8425333 9240934 10267083 11537966 13079460 ... 31 | ## $ gdpPercap: num 779 821 853 836 740 ... 32 | ``` 33 | 34 | drop Oceania 35 | 36 | 37 | ```r 38 | gapminder <- droplevels(subset(gapminder, continent != "Oceania")) 39 | ``` 40 | 41 | Note that the gapminder package ships with color schemes for countries and continents. 42 | 43 | 44 | ```r 45 | head(country_colors) 46 | ``` 47 | 48 | ``` 49 | ## Nigeria Egypt Ethiopia Congo, Dem. Rep. 50 | ## "#7F3B08" "#833D07" "#873F07" "#8B4107" 51 | ## South Africa Sudan 52 | ## "#8F4407" "#934607" 53 | ``` 54 | 55 | ```r 56 | jYear <- 2007 # this can obviously be changed 57 | jPch <- 21 58 | jDarkGray <- 'grey20' 59 | jXlim <- c(150, 115000) 60 | jYlim <- c(16, 100) 61 | 62 | ggplot(subset(gapminder, year == jYear), 63 | aes(x = gdpPercap, y = lifeExp)) + 64 | scale_x_log10(limits = jXlim) + ylim(jYlim) + 65 | geom_point(aes(size = sqrt(pop/pi)), pch = jPch, color = jDarkGray, 66 | show_guide = FALSE) + 67 | scale_size_continuous(range=c(1,40)) + 68 | facet_wrap(~ continent) + coord_fixed(ratio = 1/43) + 69 | aes(fill = country) + scale_fill_manual(values = country_colors) + 70 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 71 | ``` 72 | 73 | ![](figure/shock-awe-unnamed-chunk-4-1.png) 74 | 75 | ```r 76 | ggplot(gapminder, aes(x = year, y = lifeExp, group = country)) + 77 | geom_line(lwd = 1, show_guide = FALSE) + facet_wrap(~ continent) + 78 | aes(color = country) + scale_color_manual(values = country_colors) + 79 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 80 | ``` 81 | 82 | ![](figure/shock-awe-unnamed-chunk-4-2.png) 83 | 84 | 85 | --- 86 | title: "gapminder-ggplot2-shock-and-awe.r" 87 | author: "jenny" 88 | date: "Thu May 14 13:06:07 2015" 89 | --- 90 | -------------------------------------------------------------------------------- /gapminder-ggplot2-shock-and-awe.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: 4 | #' html_document: 5 | #' keep_md: TRUE 6 | #' --- 7 | 8 | #+ setup, include = FALSE 9 | library(knitr) 10 | opts_chunk$set(fig.path = 'figure/shock-awe-', error = TRUE) 11 | 12 | #' Note: this HTML is made by applying `knitr::spin()` to an R script. So the 13 | #' narrative is very minimal. 14 | 15 | library(ggplot2) 16 | 17 | #' pick a way to load the data 18 | #gdURL <- "http://tiny.cc/gapminder" 19 | #gapminder <- read.delim(file = gdURL) 20 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 21 | library(gapminder) 22 | str(gapminder) 23 | 24 | #' drop Oceania 25 | gapminder <- droplevels(subset(gapminder, continent != "Oceania")) 26 | 27 | #' Note that the gapminder package ships with color schemes for countries and continents. 28 | head(country_colors) 29 | 30 | jYear <- 2007 # this can obviously be changed 31 | jPch <- 21 32 | jDarkGray <- 'grey20' 33 | jXlim <- c(150, 115000) 34 | jYlim <- c(16, 100) 35 | 36 | ggplot(subset(gapminder, year == jYear), 37 | aes(x = gdpPercap, y = lifeExp)) + 38 | scale_x_log10(limits = jXlim) + ylim(jYlim) + 39 | geom_point(aes(size = sqrt(pop/pi)), pch = jPch, color = jDarkGray, 40 | show_guide = FALSE) + 41 | scale_size_continuous(range=c(1,40)) + 42 | facet_wrap(~ continent) + coord_fixed(ratio = 1/43) + 43 | aes(fill = country) + scale_fill_manual(values = country_colors) + 44 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 45 | 46 | ggplot(gapminder, aes(x = year, y = lifeExp, group = country)) + 47 | geom_line(lwd = 1, show_guide = FALSE) + facet_wrap(~ continent) + 48 | aes(color = country) + scale_color_manual(values = country_colors) + 49 | theme_bw() + theme(strip.text = element_text(size = rel(1.1))) 50 | 51 | -------------------------------------------------------------------------------- /gapminder-ggplot2-stripplot.md: -------------------------------------------------------------------------------- 1 | Jenny Bryan 2 | 3 | 4 | 5 | Note: this HTML is made by applying `knitr::spin()` to an R script. So the 6 | narrative is very minimal. 7 | 8 | 9 | ```r 10 | library(ggplot2) 11 | ``` 12 | 13 | pick a way to load the data 14 | 15 | 16 | ```r 17 | #gdURL <- "http://tiny.cc/gapminder" 18 | #gapminder <- read.delim(file = gdURL) 19 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 20 | library(gapminder) 21 | str(gapminder) 22 | ``` 23 | 24 | ``` 25 | ## 'data.frame': 1704 obs. of 6 variables: 26 | ## $ country : Factor w/ 142 levels "Afghanistan",..: 1 1 1 1 1 1 1 1 1 1 ... 27 | ## $ continent: Factor w/ 5 levels "Africa","Americas",..: 3 3 3 3 3 3 3 3 3 3 ... 28 | ## $ year : num 1952 1957 1962 1967 1972 ... 29 | ## $ lifeExp : num 28.8 30.3 32 34 36.1 ... 30 | ## $ pop : num 8425333 9240934 10267083 11537966 13079460 ... 31 | ## $ gdpPercap: num 779 821 853 836 740 ... 32 | ``` 33 | 34 | stripplots: univariate scatterplots (but w/ ways to also convey 1+ factors) 35 | 36 | 37 | ```r 38 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_point() 39 | ``` 40 | 41 | ![](figure/stripplot-unnamed-chunk-3-1.png) 42 | 43 | we have an overplotting problem; need to spread things out 44 | 45 | 46 | ```r 47 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_jitter() 48 | ``` 49 | 50 | ![](figure/stripplot-unnamed-chunk-4-1.png) 51 | 52 | we can have less jitter in x, no jitter in y, more alpha transparency 53 | 54 | 55 | ```r 56 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 57 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 58 | ``` 59 | 60 | ![](figure/stripplot-unnamed-chunk-5-1.png) 61 | 62 | boxplots -- covered properly elsewhere 63 | 64 | 65 | ```r 66 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_boxplot() 67 | ``` 68 | 69 | ![](figure/stripplot-unnamed-chunk-6-1.png) 70 | 71 | raw data AND boxplots 72 | 73 | 74 | ```r 75 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 76 | geom_boxplot(outlier.colour = "hotpink") + 77 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 78 | ``` 79 | 80 | ![](figure/stripplot-unnamed-chunk-7-1.png) 81 | 82 | superpose a statistical summary 83 | 84 | 85 | ```r 86 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 87 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 88 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 89 | ``` 90 | 91 | ![](figure/stripplot-unnamed-chunk-8-1.png) 92 | 93 | let's reorder the continent factor based on lifeExp 94 | 95 | 96 | ```r 97 | ggplot(gapminder, aes(reorder(x = continent, lifeExp), y = lifeExp)) + 98 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 99 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 100 | ``` 101 | 102 | ![](figure/stripplot-unnamed-chunk-9-1.png) 103 | 104 | ```r 105 | sessionInfo() 106 | ``` 107 | 108 | ``` 109 | ## R version 3.1.2 (2014-10-31) 110 | ## Platform: x86_64-apple-darwin10.8.0 (64-bit) 111 | ## 112 | ## locale: 113 | ## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 114 | ## 115 | ## attached base packages: 116 | ## [1] stats graphics grDevices utils datasets methods base 117 | ## 118 | ## other attached packages: 119 | ## [1] gapminder_0.1.0 ggplot2_1.0.0 knitr_1.10.5 120 | ## 121 | ## loaded via a namespace (and not attached): 122 | ## [1] colorspace_1.2-4 digest_0.6.8 evaluate_0.7 123 | ## [4] formatR_1.2 grid_3.1.2 gtable_0.1.2 124 | ## [7] htmltools_0.2.6 labeling_0.3 magrittr_1.5 125 | ## [10] MASS_7.3-35 munsell_0.4.2 plyr_1.8.2 126 | ## [13] proto_0.3-10 Rcpp_0.11.6 reshape2_1.4.0.99 127 | ## [16] rmarkdown_0.5.1 scales_0.2.4 stringi_0.4-1 128 | ## [19] stringr_1.0.0 tools_3.1.2 yaml_2.1.13 129 | ``` 130 | 131 | 132 | --- 133 | title: "gapminder-ggplot2-stripplot.r" 134 | author: "jenny" 135 | date: "Thu May 14 12:50:06 2015" 136 | --- 137 | -------------------------------------------------------------------------------- /gapminder-ggplot2-stripplot.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: 4 | #' html_document: 5 | #' keep_md: TRUE 6 | #' --- 7 | 8 | #+ setup, include = FALSE 9 | library(knitr) 10 | opts_chunk$set(fig.path = 'figure/stripplot-', error = TRUE) 11 | 12 | #' Note: this HTML is made by applying `knitr::spin()` to an R script. So the 13 | #' narrative is very minimal. 14 | 15 | library(ggplot2) 16 | 17 | #' pick a way to load the data 18 | #gdURL <- "http://tiny.cc/gapminder" 19 | #gapminder <- read.delim(file = gdURL) 20 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 21 | library(gapminder) 22 | str(gapminder) 23 | 24 | #' stripplots: univariate scatterplots (but w/ ways to also convey 1+ factors) 25 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_point() 26 | 27 | #' we have an overplotting problem; need to spread things out 28 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_jitter() 29 | 30 | #' we can have less jitter in x, no jitter in y, more alpha transparency 31 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 32 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 33 | 34 | #' boxplots -- covered properly elsewhere 35 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + geom_boxplot() 36 | 37 | #' raw data AND boxplots 38 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 39 | geom_boxplot(outlier.colour = "hotpink") + 40 | geom_jitter(position = position_jitter(width = 0.1, height = 0), alpha = 1/4) 41 | 42 | #' superpose a statistical summary 43 | ggplot(gapminder, aes(x = continent, y = lifeExp)) + 44 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 45 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 46 | 47 | #' let's reorder the continent factor based on lifeExp 48 | ggplot(gapminder, aes(reorder(x = continent, lifeExp), y = lifeExp)) + 49 | geom_jitter(position = position_jitter(width = 0.1), alpha = 1/4) + 50 | stat_summary(fun.y = median, colour = "red", geom = "point", size = 5) 51 | 52 | sessionInfo() 53 | -------------------------------------------------------------------------------- /gapminder-ggplot2-themes.md: -------------------------------------------------------------------------------- 1 | Jenny Bryan 2 | 3 | 4 | 5 | Note: this HTML is made by applying `knitr::spin()` to an R script. So the 6 | narrative is very minimal. 7 | 8 | 9 | ```r 10 | library(ggplot2) 11 | library(ggthemes) 12 | ``` 13 | 14 | pick a way to load the data 15 | 16 | 17 | ```r 18 | #gdURL <- "http://tiny.cc/gapminder" 19 | #gapminder <- read.delim(file = gdURL) 20 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 21 | library(gapminder) 22 | str(gapminder) 23 | ``` 24 | 25 | ``` 26 | ## 'data.frame': 1704 obs. of 6 variables: 27 | ## $ country : Factor w/ 142 levels "Afghanistan",..: 1 1 1 1 1 1 1 1 1 1 ... 28 | ## $ continent: Factor w/ 5 levels "Africa","Americas",..: 3 3 3 3 3 3 3 3 3 3 ... 29 | ## $ year : num 1952 1957 1962 1967 1972 ... 30 | ## $ lifeExp : num 28.8 30.3 32 34 36.1 ... 31 | ## $ pop : num 8425333 9240934 10267083 11537966 13079460 ... 32 | ## $ gdpPercap: num 779 821 853 836 740 ... 33 | ``` 34 | 35 | revisit a plot from earlier 36 | 37 | 38 | ```r 39 | p <- ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) 40 | p <- p + scale_x_log10() 41 | p <- p + aes(color = continent) + geom_point() + geom_smooth(lwd = 3, se = FALSE) 42 | p 43 | ``` 44 | 45 | ![](figure/themes-unnamed-chunk-3-1.png) 46 | 47 | give it a title 48 | 49 | 50 | ```r 51 | p + ggtitle("Life expectancy over time by continent") 52 | ``` 53 | 54 | ![](figure/themes-unnamed-chunk-4-1.png) 55 | 56 | change overall look and feel with a premade theme 57 | 58 | 59 | ```r 60 | p + theme_grey() # the default 61 | ``` 62 | 63 | ![](figure/themes-unnamed-chunk-5-1.png) 64 | 65 | suppress the usual grey background 66 | 67 | 68 | ```r 69 | p + theme_bw() 70 | ``` 71 | 72 | ![](figure/themes-unnamed-chunk-6-1.png) 73 | 74 | exploring some themes from the ggthemes package 75 | https://github.com/jrnold/ggthemes 76 | 77 | 78 | ```r 79 | p + theme_calc() + ggtitle("ggthemes::theme_calc()") 80 | ``` 81 | 82 | ![](figure/themes-unnamed-chunk-7-1.png) 83 | 84 | ```r 85 | p + theme_economist() + ggtitle("ggthemes::theme_economist()") 86 | ``` 87 | 88 | ![](figure/themes-unnamed-chunk-7-2.png) 89 | 90 | ```r 91 | p + theme_economist_white() + ggtitle("ggthemes::theme_economist_white()") 92 | ``` 93 | 94 | ![](figure/themes-unnamed-chunk-7-3.png) 95 | 96 | ```r 97 | p + theme_few() + ggtitle("ggthemes::theme_few()") 98 | ``` 99 | 100 | ![](figure/themes-unnamed-chunk-7-4.png) 101 | 102 | ```r 103 | p + theme_gdocs() + ggtitle("ggthemes::theme_gdocs()") 104 | ``` 105 | 106 | ![](figure/themes-unnamed-chunk-7-5.png) 107 | 108 | ```r 109 | p + theme_tufte() + ggtitle("ggthemes::theme_tufte()") 110 | ``` 111 | 112 | ![](figure/themes-unnamed-chunk-7-6.png) 113 | 114 | ```r 115 | p + theme_wsj() + ggtitle("ggthemes::theme_wsj()") 116 | ``` 117 | 118 | ![](figure/themes-unnamed-chunk-7-7.png) 119 | 120 | ```r 121 | sessionInfo() 122 | ``` 123 | 124 | ``` 125 | ## R version 3.1.2 (2014-10-31) 126 | ## Platform: x86_64-apple-darwin10.8.0 (64-bit) 127 | ## 128 | ## locale: 129 | ## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 130 | ## 131 | ## attached base packages: 132 | ## [1] stats graphics grDevices utils datasets methods base 133 | ## 134 | ## other attached packages: 135 | ## [1] gapminder_0.1.0 ggthemes_1.7.0 ggplot2_1.0.0 knitr_1.10.5 136 | ## 137 | ## loaded via a namespace (and not attached): 138 | ## [1] colorspace_1.2-4 digest_0.6.8 evaluate_0.7 139 | ## [4] formatR_1.2 grid_3.1.2 gtable_0.1.2 140 | ## [7] htmltools_0.2.6 labeling_0.3 magrittr_1.5 141 | ## [10] MASS_7.3-35 munsell_0.4.2 plyr_1.8.2 142 | ## [13] proto_0.3-10 Rcpp_0.11.6 reshape2_1.4.0.99 143 | ## [16] rmarkdown_0.5.1 scales_0.2.4 stringi_0.4-1 144 | ## [19] stringr_1.0.0 tools_3.1.2 yaml_2.1.13 145 | ``` 146 | 147 | 148 | --- 149 | title: "gapminder-ggplot2-themes.r" 150 | author: "jenny" 151 | date: "Thu May 14 12:56:09 2015" 152 | --- 153 | -------------------------------------------------------------------------------- /gapminder-ggplot2-themes.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: 4 | #' html_document: 5 | #' keep_md: TRUE 6 | #' --- 7 | 8 | #+ setup, include = FALSE 9 | library(knitr) 10 | opts_chunk$set(fig.path = 'figure/themes-', error = TRUE) 11 | 12 | #' Note: this HTML is made by applying `knitr::spin()` to an R script. So the 13 | #' narrative is very minimal. 14 | 15 | library(ggplot2) 16 | library(ggthemes) 17 | 18 | #' pick a way to load the data 19 | #gdURL <- "http://tiny.cc/gapminder" 20 | #gapminder <- read.delim(file = gdURL) 21 | #gapminder <- read.delim("gapminderDataFiveYear.tsv") 22 | library(gapminder) 23 | str(gapminder) 24 | 25 | #' revisit a plot from earlier 26 | p <- ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) 27 | p <- p + scale_x_log10() 28 | p <- p + aes(color = continent) + geom_point() + geom_smooth(lwd = 3, se = FALSE) 29 | p 30 | 31 | #' give it a title 32 | p + ggtitle("Life expectancy over time by continent") 33 | 34 | #' change overall look and feel with a premade theme 35 | p + theme_grey() # the default 36 | 37 | #' suppress the usual grey background 38 | p + theme_bw() 39 | 40 | #' exploring some themes from the ggthemes package 41 | #' https://github.com/jrnold/ggthemes 42 | p + theme_calc() + ggtitle("ggthemes::theme_calc()") 43 | p + theme_economist() + ggtitle("ggthemes::theme_economist()") 44 | p + theme_economist_white() + ggtitle("ggthemes::theme_economist_white()") 45 | p + theme_few() + ggtitle("ggthemes::theme_few()") 46 | p + theme_gdocs() + ggtitle("ggthemes::theme_gdocs()") 47 | p + theme_tufte() + ggtitle("ggthemes::theme_tufte()") 48 | p + theme_wsj() + ggtitle("ggthemes::theme_wsj()") 49 | 50 | sessionInfo() -------------------------------------------------------------------------------- /gapminder-ggplot2-univariate-factor.md: -------------------------------------------------------------------------------- 1 | gapminder-ggplot2-univariate-factor.r 2 | ================ 3 | Jenny Bryan 4 | Mon Oct 3 23:10:40 2016 5 | 6 | Note: this is rendered by applying `knitr::spin()` to an R script. So the narrative is very minimal. load the data and ggplot2 (part of the tidyverse) 7 | 8 | ``` r 9 | library(tidyverse) 10 | ``` 11 | 12 | ## Loading tidyverse: ggplot2 13 | ## Loading tidyverse: tibble 14 | ## Loading tidyverse: tidyr 15 | ## Loading tidyverse: readr 16 | ## Loading tidyverse: purrr 17 | ## Loading tidyverse: dplyr 18 | 19 | ## Conflicts with tidy packages ---------------------------------------------- 20 | 21 | ## filter(): dplyr, stats 22 | ## lag(): dplyr, stats 23 | 24 | ``` r 25 | library(gapminder) 26 | gapminder 27 | ``` 28 | 29 | ## # A tibble: 1,704 × 6 30 | ## country continent year lifeExp pop gdpPercap 31 | ## 32 | ## 1 Afghanistan Asia 1952 28.801 8425333 779.4453 33 | ## 2 Afghanistan Asia 1957 30.332 9240934 820.8530 34 | ## 3 Afghanistan Asia 1962 31.997 10267083 853.1007 35 | ## 4 Afghanistan Asia 1967 34.020 11537966 836.1971 36 | ## 5 Afghanistan Asia 1972 36.088 13079460 739.9811 37 | ## 6 Afghanistan Asia 1977 38.438 14880372 786.1134 38 | ## 7 Afghanistan Asia 1982 39.854 12881816 978.0114 39 | ## 8 Afghanistan Asia 1987 40.822 13867957 852.3959 40 | ## 9 Afghanistan Asia 1992 41.674 16317921 649.3414 41 | ## 10 Afghanistan Asia 1997 41.763 22227415 635.3414 42 | ## # ... with 1,694 more rows 43 | 44 | bar charts 45 | consider: no. of observations for each continent 46 | 47 | ``` r 48 | table(gapminder$continent) 49 | ``` 50 | 51 | ## 52 | ## Africa Americas Asia Europe Oceania 53 | ## 624 300 396 360 24 54 | 55 | this works because default stat for geom\_bar() is "bin" 56 | 57 | ``` r 58 | ggplot(gapminder, aes(x = continent)) + geom_bar() 59 | ``` 60 | 61 | ![](figure/uni-factor-unnamed-chunk-3-1.png) 62 | 63 | let's reorder the continents based on frequency 64 | 65 | ``` r 66 | p <- ggplot(gapminder, aes(x = reorder(continent, continent, length))) 67 | p + geom_bar() 68 | ``` 69 | 70 | ![](figure/uni-factor-unnamed-chunk-4-1.png) 71 | 72 | would you rather the bars run horizontally? 73 | 74 | ``` r 75 | p + geom_bar() + coord_flip() 76 | ``` 77 | 78 | ![](figure/uni-factor-unnamed-chunk-5-1.png) 79 | 80 | how about a better ratio? 81 | 82 | ``` r 83 | p + geom_bar(width = 0.05) + coord_flip() 84 | ``` 85 | 86 | ![](figure/uni-factor-unnamed-chunk-6-1.png) 87 | 88 | consider a scenario where you DON'T want the default "bin" stat, i.e. the bar length or height already exists as a variable 89 | 90 | ``` r 91 | (continent_freq <- gapminder %>% count(continent)) 92 | ``` 93 | 94 | ## # A tibble: 5 × 2 95 | ## continent n 96 | ## 97 | ## 1 Africa 624 98 | ## 2 Americas 300 99 | ## 3 Asia 396 100 | ## 4 Europe 360 101 | ## 5 Oceania 24 102 | 103 | this simple call no longer works, because we have pre-tabulated 104 | 105 | ``` r 106 | ggplot(continent_freq, aes(x = continent)) + geom_bar() 107 | ``` 108 | 109 | ![](figure/uni-factor-unnamed-chunk-8-1.png) 110 | 111 | THIS works when bar length or height already exists 112 | 113 | ``` r 114 | ggplot(continent_freq, aes(x = continent, y = n)) + geom_bar(stat = "identity") 115 | ``` 116 | 117 | ![](figure/uni-factor-unnamed-chunk-9-1.png) 118 | 119 | ``` r 120 | sessionInfo() 121 | ``` 122 | 123 | ## R version 3.3.1 (2016-06-21) 124 | ## Platform: x86_64-apple-darwin13.4.0 (64-bit) 125 | ## Running under: OS X 10.11.6 (El Capitan) 126 | ## 127 | ## locale: 128 | ## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8 129 | ## 130 | ## attached base packages: 131 | ## [1] stats graphics grDevices utils datasets methods base 132 | ## 133 | ## other attached packages: 134 | ## [1] gapminder_0.2.0 dplyr_0.5.0 purrr_0.2.2 readr_1.0.0.9000 135 | ## [5] tidyr_0.6.0.9000 tibble_1.2 ggplot2_2.1.0 tidyverse_1.0.0 136 | ## [9] knitr_1.14.2 137 | ## 138 | ## loaded via a namespace (and not attached): 139 | ## [1] Rcpp_0.12.7 magrittr_1.5 munsell_0.4.3 140 | ## [4] colorspace_1.2-6 R6_2.1.3 stringr_1.1.0 141 | ## [7] plyr_1.8.4 tools_3.3.1 grid_3.3.1 142 | ## [10] gtable_0.2.0 DBI_0.4-1 htmltools_0.3.5 143 | ## [13] lazyeval_0.2.0 yaml_2.1.13 assertthat_0.1 144 | ## [16] digest_0.6.10 formatR_1.4 evaluate_0.9 145 | ## [19] rmarkdown_1.0.9014 labeling_0.3 stringi_1.1.1 146 | ## [22] scales_0.4.0 147 | -------------------------------------------------------------------------------- /gapminder-ggplot2-univariate-factor.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: github_document 4 | #' --- 5 | 6 | #+ setup, include = FALSE 7 | library(knitr) 8 | opts_chunk$set(fig.path = 'figure/uni-factor-', error = TRUE) 9 | 10 | #' Note: this is rendered by applying `knitr::spin()` to an R script. So the 11 | #' narrative is very minimal. 12 | 13 | 14 | 15 | #' load the data and ggplot2 (part of the tidyverse) 16 | library(tidyverse) 17 | library(gapminder) 18 | gapminder 19 | 20 | #' bar charts 21 | #' consider: no. of observations for each continent 22 | table(gapminder$continent) 23 | 24 | #' this works because default stat for geom_bar() is "bin" 25 | ggplot(gapminder, aes(x = continent)) + geom_bar() 26 | 27 | #' let's reorder the continents based on frequency 28 | p <- ggplot(gapminder, aes(x = reorder(continent, continent, length))) 29 | p + geom_bar() 30 | 31 | #' would you rather the bars run horizontally? 32 | p + geom_bar() + coord_flip() 33 | 34 | #' how about a better data:ink ratio? 35 | p + geom_bar(width = 0.05) + coord_flip() 36 | 37 | #' consider a scenario where you DON'T want the default "bin" stat, i.e. the bar 38 | #' length or height already exists as a variable 39 | (continent_freq <- gapminder %>% count(continent)) 40 | 41 | #' this simple call no longer works, because we have pre-tabulated 42 | ggplot(continent_freq, aes(x = continent)) + geom_bar() 43 | 44 | #' THIS works when bar length or height already exists 45 | ggplot(continent_freq, aes(x = continent, y = n)) + geom_bar(stat = "identity") 46 | 47 | sessionInfo() 48 | -------------------------------------------------------------------------------- /gapminder-ggplot2-univariate-quantitative.md: -------------------------------------------------------------------------------- 1 | gapminder-ggplot2-univariate-quantitative.r 2 | ================ 3 | Jenny Bryan 4 | Mon Oct 3 23:49:33 2016 5 | 6 | Note: this is rendered by applying `knitr::spin()` to an R script. So the narrative is very minimal. load the data and ggplot2 (part of the tidyverse) 7 | 8 | ``` r 9 | library(tidyverse) 10 | ``` 11 | 12 | ## Loading tidyverse: ggplot2 13 | ## Loading tidyverse: tibble 14 | ## Loading tidyverse: tidyr 15 | ## Loading tidyverse: readr 16 | ## Loading tidyverse: purrr 17 | ## Loading tidyverse: dplyr 18 | 19 | ## Conflicts with tidy packages ---------------------------------------------- 20 | 21 | ## filter(): dplyr, stats 22 | ## lag(): dplyr, stats 23 | 24 | ``` r 25 | library(gapminder) 26 | gapminder 27 | ``` 28 | 29 | ## # A tibble: 1,704 × 6 30 | ## country continent year lifeExp pop gdpPercap 31 | ## 32 | ## 1 Afghanistan Asia 1952 28.801 8425333 779.4453 33 | ## 2 Afghanistan Asia 1957 30.332 9240934 820.8530 34 | ## 3 Afghanistan Asia 1962 31.997 10267083 853.1007 35 | ## 4 Afghanistan Asia 1967 34.020 11537966 836.1971 36 | ## 5 Afghanistan Asia 1972 36.088 13079460 739.9811 37 | ## 6 Afghanistan Asia 1977 38.438 14880372 786.1134 38 | ## 7 Afghanistan Asia 1982 39.854 12881816 978.0114 39 | ## 8 Afghanistan Asia 1987 40.822 13867957 852.3959 40 | ## 9 Afghanistan Asia 1992 41.674 16317921 649.3414 41 | ## 10 Afghanistan Asia 1997 41.763 22227415 635.3414 42 | ## # ... with 1,694 more rows 43 | 44 | distribution of a quant var: histogram 45 | 46 | ``` r 47 | ggplot(gapminder, aes(x = lifeExp)) + 48 | geom_histogram() 49 | ``` 50 | 51 | ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. 52 | 53 | ![](figure/uni-quant-unnamed-chunk-2-1.png) 54 | 55 | experiment with bin width; think in terms of the units of the x variable 56 | 57 | ``` r 58 | ggplot(gapminder, aes(x = lifeExp)) + 59 | geom_histogram(binwidth = 1) 60 | ``` 61 | 62 | ![](figure/uni-quant-unnamed-chunk-3-1.png) 63 | 64 | show the different continents, but it's weird to stack up the histograms, which is what default of `position = "stack"` delivers 65 | 66 | ``` r 67 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 68 | geom_histogram() 69 | ``` 70 | 71 | ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. 72 | 73 | ![](figure/uni-quant-unnamed-chunk-4-1.png) 74 | 75 | `position = "identity"` is good to know about it's still weird to layer them on top of each other like this 76 | 77 | ``` r 78 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 79 | geom_histogram(position = "identity") 80 | ``` 81 | 82 | ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. 83 | 84 | ![](figure/uni-quant-unnamed-chunk-5-1.png) 85 | 86 | geom\_freqpoly() is better in this case 87 | 88 | ``` r 89 | ggplot(gapminder, aes(x = lifeExp, color = continent)) + 90 | geom_freqpoly() 91 | ``` 92 | 93 | ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. 94 | 95 | ![](figure/uni-quant-unnamed-chunk-6-1.png) 96 | 97 | smooth histogram = densityplot 98 | 99 | ``` r 100 | ggplot(gapminder, aes(x = lifeExp)) + geom_density() 101 | ``` 102 | 103 | ![](figure/uni-quant-unnamed-chunk-7-1.png) 104 | 105 | you should look at different levels of smoothing 106 | 107 | ``` r 108 | ggplot(gapminder, aes(x = lifeExp)) + geom_density(adjust = 1) 109 | ``` 110 | 111 | ![](figure/uni-quant-unnamed-chunk-8-1.png) 112 | 113 | ``` r 114 | ggplot(gapminder, aes(x = lifeExp)) + geom_density(adjust = 0.2) 115 | ``` 116 | 117 | ![](figure/uni-quant-unnamed-chunk-8-2.png) 118 | 119 | densityplots work better in terms of one continent not obscuring another 120 | 121 | ``` r 122 | ggplot(gapminder, aes(x = lifeExp, color = continent)) + geom_density() 123 | ``` 124 | 125 | ![](figure/uni-quant-unnamed-chunk-9-1.png) 126 | 127 | alpha transparency works here too 128 | 129 | ``` r 130 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 131 | geom_density(alpha = 0.2) 132 | ``` 133 | 134 | ![](figure/uni-quant-unnamed-chunk-10-1.png) 135 | 136 | with only two countries, maybe we should ignore Oceania? 137 | 138 | ``` r 139 | ggplot(subset(gapminder, continent != "Oceania"), 140 | aes(x = lifeExp, fill = continent)) + geom_density(alpha = 0.2) 141 | ``` 142 | 143 | ![](figure/uni-quant-unnamed-chunk-11-1.png) 144 | 145 | facets work here too 146 | 147 | ``` r 148 | ggplot(gapminder, aes(x = lifeExp)) + geom_density() + facet_wrap(~ continent) 149 | ``` 150 | 151 | ![](figure/uni-quant-unnamed-chunk-12-1.png) 152 | 153 | ``` r 154 | ggplot(subset(gapminder, continent != "Oceania"), 155 | aes(x = lifeExp, fill = continent)) + geom_histogram() + 156 | facet_grid(continent ~ .) 157 | ``` 158 | 159 | ## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`. 160 | 161 | ![](figure/uni-quant-unnamed-chunk-12-2.png) 162 | 163 | boxplot for one quantitative variable against a discrete variable 164 | first attempt does not work since year is not formally a factor 165 | 166 | ``` r 167 | ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_boxplot() 168 | ``` 169 | 170 | ## Warning: Continuous x aesthetic -- did you forget aes(group=...)? 171 | 172 | ![](figure/uni-quant-unnamed-chunk-13-1.png) 173 | 174 | by explicitly specifying year as the grouping variable, we get what we want 175 | 176 | ``` r 177 | ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_boxplot(aes(group = year)) 178 | ``` 179 | 180 | ![](figure/uni-quant-unnamed-chunk-14-1.png) 181 | 182 | try geom\_violin() instead and just generally goofing off now 183 | 184 | ``` r 185 | ggplot(gapminder, aes(x = year, y = lifeExp)) + 186 | geom_violin(aes(group = year)) + 187 | geom_jitter(alpha = 1/4) + 188 | geom_smooth(se = FALSE) 189 | ``` 190 | 191 | ![](figure/uni-quant-unnamed-chunk-15-1.png) 192 | -------------------------------------------------------------------------------- /gapminder-ggplot2-univariate-quantitative.r: -------------------------------------------------------------------------------- 1 | #' --- 2 | #' author: "Jenny Bryan" 3 | #' output: github_document 4 | #' --- 5 | 6 | #+ setup, include = FALSE 7 | library(knitr) 8 | opts_chunk$set(fig.path = 'figure/uni-quant-', error = TRUE) 9 | 10 | #' Note: this is rendered by applying `knitr::spin()` to an R script. So the 11 | #' narrative is very minimal. 12 | 13 | #' load the data and ggplot2 (part of the tidyverse) 14 | library(tidyverse) 15 | library(gapminder) 16 | gapminder 17 | 18 | #' distribution of a quant var: histogram 19 | ggplot(gapminder, aes(x = lifeExp)) + 20 | geom_histogram() 21 | 22 | #' experiment with bin width; think in terms of the units of the x variable 23 | ggplot(gapminder, aes(x = lifeExp)) + 24 | geom_histogram(binwidth = 1) 25 | 26 | #' show the different continents, but it's weird to stack up the 27 | #' histograms, which is what default of `position = "stack"` delivers 28 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 29 | geom_histogram() 30 | 31 | #' `position = "identity"` is good to know about 32 | #' it's still weird to layer them on top of each other like this 33 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 34 | geom_histogram(position = "identity") 35 | 36 | #' geom_freqpoly() is better in this case 37 | ggplot(gapminder, aes(x = lifeExp, color = continent)) + 38 | geom_freqpoly() 39 | 40 | #' smooth histogram = densityplot 41 | ggplot(gapminder, aes(x = lifeExp)) + geom_density() 42 | 43 | #' you should look at different levels of smoothing 44 | ggplot(gapminder, aes(x = lifeExp)) + geom_density(adjust = 1) 45 | ggplot(gapminder, aes(x = lifeExp)) + geom_density(adjust = 0.2) 46 | 47 | #' densityplots work better in terms of one continent not obscuring another 48 | ggplot(gapminder, aes(x = lifeExp, color = continent)) + geom_density() 49 | 50 | #' alpha transparency works here too 51 | ggplot(gapminder, aes(x = lifeExp, fill = continent)) + 52 | geom_density(alpha = 0.2) 53 | 54 | #' with only two countries, maybe we should ignore Oceania? 55 | ggplot(subset(gapminder, continent != "Oceania"), 56 | aes(x = lifeExp, fill = continent)) + geom_density(alpha = 0.2) 57 | 58 | #' facets work here too 59 | ggplot(gapminder, aes(x = lifeExp)) + geom_density() + facet_wrap(~ continent) 60 | 61 | ggplot(subset(gapminder, continent != "Oceania"), 62 | aes(x = lifeExp, fill = continent)) + geom_histogram() + 63 | facet_grid(continent ~ .) 64 | 65 | #' boxplot for one quantitative variable against a discrete variable 66 | #' first attempt does not work since year is not formally a factor 67 | ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_boxplot() 68 | 69 | #' by explicitly specifying year as the grouping variable, we get what we want 70 | ggplot(gapminder, aes(x = year, y = lifeExp)) + geom_boxplot(aes(group = year)) 71 | 72 | #' try geom_violin() instead and just generally goofing off now 73 | ggplot(gapminder, aes(x = year, y = lifeExp)) + 74 | geom_violin(aes(group = year)) + 75 | geom_jitter(alpha = 1/4) + 76 | geom_smooth(se = FALSE) 77 | 78 | -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: 3 | html_document: 4 | keep_md: TRUE 5 | --- 6 | 7 | ```{r, results ="asis", echo = FALSE} 8 | fig_files <- dir(pattern = "png$") 9 | cat(paste0("* ", fig_files, " ![](", fig_files, ")\n")) 10 | ``` 11 | -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/README.md: -------------------------------------------------------------------------------- 1 | 2 | * ggplot2-tutorial-slides.001.png ![](ggplot2-tutorial-slides.001.png) 3 | * ggplot2-tutorial-slides.002.png ![](ggplot2-tutorial-slides.002.png) 4 | * ggplot2-tutorial-slides.003.png ![](ggplot2-tutorial-slides.003.png) 5 | * ggplot2-tutorial-slides.004.png ![](ggplot2-tutorial-slides.004.png) 6 | * ggplot2-tutorial-slides.005.png ![](ggplot2-tutorial-slides.005.png) 7 | * ggplot2-tutorial-slides.006.png ![](ggplot2-tutorial-slides.006.png) 8 | * ggplot2-tutorial-slides.007.png ![](ggplot2-tutorial-slides.007.png) 9 | * ggplot2-tutorial-slides.008.png ![](ggplot2-tutorial-slides.008.png) 10 | * ggplot2-tutorial-slides.009.png ![](ggplot2-tutorial-slides.009.png) 11 | * ggplot2-tutorial-slides.010.png ![](ggplot2-tutorial-slides.010.png) 12 | * ggplot2-tutorial-slides.011.png ![](ggplot2-tutorial-slides.011.png) 13 | * ggplot2-tutorial-slides.012.png ![](ggplot2-tutorial-slides.012.png) 14 | * ggplot2-tutorial-slides.013.png ![](ggplot2-tutorial-slides.013.png) 15 | * ggplot2-tutorial-slides.014.png ![](ggplot2-tutorial-slides.014.png) 16 | * ggplot2-tutorial-slides.015.png ![](ggplot2-tutorial-slides.015.png) 17 | * ggplot2-tutorial-slides.016.png ![](ggplot2-tutorial-slides.016.png) 18 | * ggplot2-tutorial-slides.017.png ![](ggplot2-tutorial-slides.017.png) 19 | * ggplot2-tutorial-slides.018.png ![](ggplot2-tutorial-slides.018.png) 20 | * ggplot2-tutorial-slides.019.png ![](ggplot2-tutorial-slides.019.png) 21 | * ggplot2-tutorial-slides.020.png ![](ggplot2-tutorial-slides.020.png) 22 | * ggplot2-tutorial-slides.021.png ![](ggplot2-tutorial-slides.021.png) 23 | * ggplot2-tutorial-slides.022.png ![](ggplot2-tutorial-slides.022.png) 24 | * ggplot2-tutorial-slides.023.png ![](ggplot2-tutorial-slides.023.png) 25 | * ggplot2-tutorial-slides.024.png ![](ggplot2-tutorial-slides.024.png) 26 | * ggplot2-tutorial-slides.025.png ![](ggplot2-tutorial-slides.025.png) 27 | * ggplot2-tutorial-slides.026.png ![](ggplot2-tutorial-slides.026.png) 28 | * ggplot2-tutorial-slides.027.png ![](ggplot2-tutorial-slides.027.png) 29 | * ggplot2-tutorial-slides.028.png ![](ggplot2-tutorial-slides.028.png) 30 | * ggplot2-tutorial-slides.029.png ![](ggplot2-tutorial-slides.029.png) 31 | * ggplot2-tutorial-slides.030.png ![](ggplot2-tutorial-slides.030.png) 32 | * ggplot2-tutorial-slides.031.png ![](ggplot2-tutorial-slides.031.png) 33 | * ggplot2-tutorial-slides.032.png ![](ggplot2-tutorial-slides.032.png) 34 | * ggplot2-tutorial-slides.033.png ![](ggplot2-tutorial-slides.033.png) 35 | * ggplot2-tutorial-slides.034.png ![](ggplot2-tutorial-slides.034.png) 36 | * ggplot2-tutorial-slides.035.png ![](ggplot2-tutorial-slides.035.png) 37 | * ggplot2-tutorial-slides.036.png ![](ggplot2-tutorial-slides.036.png) 38 | * ggplot2-tutorial-slides.037.png ![](ggplot2-tutorial-slides.037.png) 39 | * ggplot2-tutorial-slides.038.png ![](ggplot2-tutorial-slides.038.png) 40 | * ggplot2-tutorial-slides.039.png ![](ggplot2-tutorial-slides.039.png) 41 | * ggplot2-tutorial-slides.040.png ![](ggplot2-tutorial-slides.040.png) 42 | * ggplot2-tutorial-slides.041.png ![](ggplot2-tutorial-slides.041.png) 43 | * ggplot2-tutorial-slides.042.png ![](ggplot2-tutorial-slides.042.png) 44 | * ggplot2-tutorial-slides.043.png ![](ggplot2-tutorial-slides.043.png) 45 | * ggplot2-tutorial-slides.044.png ![](ggplot2-tutorial-slides.044.png) 46 | * ggplot2-tutorial-slides.045.png ![](ggplot2-tutorial-slides.045.png) 47 | * ggplot2-tutorial-slides.046.png ![](ggplot2-tutorial-slides.046.png) 48 | * ggplot2-tutorial-slides.047.png ![](ggplot2-tutorial-slides.047.png) 49 | * ggplot2-tutorial-slides.048.png ![](ggplot2-tutorial-slides.048.png) 50 | * ggplot2-tutorial-slides.049.png ![](ggplot2-tutorial-slides.049.png) 51 | * ggplot2-tutorial-slides.050.png ![](ggplot2-tutorial-slides.050.png) 52 | * ggplot2-tutorial-slides.051.png ![](ggplot2-tutorial-slides.051.png) 53 | * ggplot2-tutorial-slides.052.png ![](ggplot2-tutorial-slides.052.png) 54 | * ggplot2-tutorial-slides.053.png ![](ggplot2-tutorial-slides.053.png) 55 | * ggplot2-tutorial-slides.054.png ![](ggplot2-tutorial-slides.054.png) 56 | * ggplot2-tutorial-slides.055.png ![](ggplot2-tutorial-slides.055.png) 57 | * ggplot2-tutorial-slides.056.png ![](ggplot2-tutorial-slides.056.png) 58 | -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.001.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.002.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.002.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.003.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.004.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.005.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.005.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.006.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.007.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.007.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.008.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.008.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.009.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.009.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.010.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.011.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.011.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.012.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.012.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.013.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.013.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.014.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.015.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.016.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.016.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.017.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.018.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.019.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.020.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.020.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.021.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.021.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.022.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.022.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.023.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.023.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.024.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.025.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.025.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.026.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.026.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.027.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.027.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.028.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.028.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.029.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.029.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.030.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.030.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.031.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.031.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.032.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.032.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.033.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.033.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.034.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.035.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.036.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.036.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.037.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.037.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.038.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.038.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.039.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.039.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.040.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.040.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.041.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.041.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.042.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.042.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.043.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.043.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.044.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.044.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.045.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.045.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.046.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.047.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.047.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.048.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.049.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.049.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.050.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.050.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.051.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.051.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.052.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.052.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.053.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.053.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.054.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.054.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.055.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.055.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.056.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.056.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.057.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.057.png -------------------------------------------------------------------------------- /ggplot2-tutorial-slides/ggplot2-tutorial-slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jennybc/ggplot2-tutorial/c5e9c2605bfb7a22fc3337f3589c9843ad4168c8/ggplot2-tutorial-slides/ggplot2-tutorial-slides.pdf --------------------------------------------------------------------------------