class: center, middle, inverse, title-slide # core tidyverse downloads isotype plot ## using ggtextures - Gina Reynolds ###
2018/09/16 --- --- # Let's make this plot <img src="figures/isoplot.png" width="65%" style="display: block; margin: auto;" /> --- # Tidyverse packages used There are in fact a number of ["core" tidyverse packages](https://www.tidyverse.org/) used in this demo! - tibble - ggplot - stringr - tidyr - dplyr Let's load these packages, with the `tidyverse` wrapper package that loads them all. ```r library(tidyverse) ``` --- # ggtextures ggtextures is a new package under development by Claus Wilke which is available on github. https://github.com/clauswilke/ggtextures It can be installed using devtools: ```r devtools::install_github("clauswilke/ggtextures") ``` We load this one, and a few others. ```r library(ggtextures) library(grid) library(magick) ``` --- # Creating a tibble with the core tidyverse hex stickers --- class: split-40 count: false .column[.content[ ```r *# vector of core tidyverse package names *c("ggplot2", "dplyr", "tidyr", "readr", "purrr", * "tibble", "stringr", "forcats", "tidyverse") ``` ]] .column[.content[ ``` ## [1] "ggplot2" "dplyr" "tidyr" "readr" "purrr" "tibble" ## [7] "stringr" "forcats" "tidyverse" ``` ]] --- class: split-40 count: false .column[.content[ ```r # vector of core tidyverse package names c("ggplot2", "dplyr", "tidyr", "readr", "purrr", "tibble", "stringr", "forcats", "tidyverse") -> *package ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r # vector of core tidyverse package names c("ggplot2", "dplyr", "tidyr", "readr", "purrr", "tibble", "stringr", "forcats", "tidyverse") -> package *# the paths of the hex stickers online *paste0("https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/", * package, ".svg") ``` ]] .column[.content[ ``` ## [1] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/ggplot2.svg" ## [2] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/dplyr.svg" ## [3] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/tidyr.svg" ## [4] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/readr.svg" ## [5] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/purrr.svg" ## [6] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/tibble.svg" ## [7] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/stringr.svg" ## [8] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/forcats.svg" ## [9] "https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/tidyverse.svg" ``` ]] --- class: split-40 count: false .column[.content[ ```r # vector of core tidyverse package names c("ggplot2", "dplyr", "tidyr", "readr", "purrr", "tibble", "stringr", "forcats", "tidyverse") -> package # the paths of the hex stickers online paste0("https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/", package, ".svg") -> * hex_url ``` ]] .column[.content[ ]] --- class: split-40 count: false .column[.content[ ```r # vector of core tidyverse package names c("ggplot2", "dplyr", "tidyr", "readr", "purrr", "tibble", "stringr", "forcats", "tidyverse") -> package # the paths of the hex stickers online paste0("https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/", package, ".svg") -> hex_url *tibble(package, * hex = list(magick::image_read_svg(hex_url[1]), * magick::image_read_svg(hex_url[2]), * magick::image_read_svg(hex_url[3]), * magick::image_read_svg(hex_url[4]), * magick::image_read_svg(hex_url[5]), * magick::image_read_svg(hex_url[6]), * magick::image_read_svg(hex_url[7]), * magick::image_read_svg(hex_url[8]), * magick::image_read_svg(hex_url[9]))) ``` ]] .column[.content[ ``` ## # A tibble: 9 x 2 ## package hex ## <chr> <list> ## 1 ggplot2 <magck-mg> ## 2 dplyr <magck-mg> ## 3 tidyr <magck-mg> ## 4 readr <magck-mg> ## 5 purrr <magck-mg> ## 6 tibble <magck-mg> ## 7 stringr <magck-mg> ## 8 forcats <magck-mg> ## 9 tidyverse <magck-mg> ``` ]] --- class: split-40 count: false .column[.content[ ```r # vector of core tidyverse package names c("ggplot2", "dplyr", "tidyr", "readr", "purrr", "tibble", "stringr", "forcats", "tidyverse") -> package # the paths of the hex stickers online paste0("https://raw.githubusercontent.com/rstudio/hex-stickers/master/SVG/", package, ".svg") -> hex_url tibble(package, hex = list(magick::image_read_svg(hex_url[1]), magick::image_read_svg(hex_url[2]), magick::image_read_svg(hex_url[3]), magick::image_read_svg(hex_url[4]), magick::image_read_svg(hex_url[5]), magick::image_read_svg(hex_url[6]), magick::image_read_svg(hex_url[7]), magick::image_read_svg(hex_url[8]), magick::image_read_svg(hex_url[9]))) -> *core_w_hex_sticker ``` ]] .column[.content[ ]] --- # Data preparation and plotting Get the package download data for September 10, 2018 from cran-logs.rstudio.com. ```r package_download_2018_09_10 <- read_csv("http://cran-logs.rstudio.com/2018/2018-09-10.csv.gz") ``` --- class: split-40 count: false .column[.content[ ```r *package_download_2018_09_10 ``` ]] .column[.content[ ``` ## # A tibble: 2,042,951 x 10 ## date time size r_version r_arch r_os package version ## <date> <time> <dbl> <chr> <chr> <chr> <chr> <chr> ## 1 2018-09-10 05:17:46 7.50e4 3.5.1 x86_64 ming… cairoD… 2.25 ## 2 2018-09-10 05:17:29 1.09e5 3.5.1 x86_64 ming… glue 1.3.0 ## 3 2018-09-10 05:17:32 1.56e5 3.5.1 x86_64 ming… magrit… 1.5 ## 4 2018-09-10 05:17:48 4.42e6 3.4.4 i386 ming… Rcpp 0.12.18 ## 5 2018-09-10 05:17:49 3.42e4 3.5.1 x86_64 darw… miniUI 0.1.1.1 ## 6 2018-09-10 05:17:51 1.36e6 3.5.1 x86_64 darw… webshot 0.5.0 ## 7 2018-09-10 05:17:55 9.31e5 3.5.1 x86_64 darw… xml2 1.2.0 ## 8 2018-09-10 05:17:52 9.69e5 3.4.4 x86_64 ming… SparseM 1.77 ## 9 2018-09-10 05:17:40 3.93e5 3.4.1 x86_64 linu… plyr 1.8.4 ## 10 2018-09-10 05:17:56 1.03e5 3.5.1 x86_64 darw… cellra… 1.1.0 ## # … with 2,042,941 more rows, and 2 more variables: country <chr>, ## # ip_id <dbl> ``` ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% * group_by(package) ``` ]] .column[.content[ ``` ## # A tibble: 2,042,951 x 10 ## # Groups: package [13,272] ## date time size r_version r_arch r_os package version ## <date> <time> <dbl> <chr> <chr> <chr> <chr> <chr> ## 1 2018-09-10 05:17:46 7.50e4 3.5.1 x86_64 ming… cairoD… 2.25 ## 2 2018-09-10 05:17:29 1.09e5 3.5.1 x86_64 ming… glue 1.3.0 ## 3 2018-09-10 05:17:32 1.56e5 3.5.1 x86_64 ming… magrit… 1.5 ## 4 2018-09-10 05:17:48 4.42e6 3.4.4 i386 ming… Rcpp 0.12.18 ## 5 2018-09-10 05:17:49 3.42e4 3.5.1 x86_64 darw… miniUI 0.1.1.1 ## 6 2018-09-10 05:17:51 1.36e6 3.5.1 x86_64 darw… webshot 0.5.0 ## 7 2018-09-10 05:17:55 9.31e5 3.5.1 x86_64 darw… xml2 1.2.0 ## 8 2018-09-10 05:17:52 9.69e5 3.4.4 x86_64 ming… SparseM 1.77 ## 9 2018-09-10 05:17:40 3.93e5 3.4.1 x86_64 linu… plyr 1.8.4 ## 10 2018-09-10 05:17:56 1.03e5 3.5.1 x86_64 darw… cellra… 1.1.0 ## # … with 2,042,941 more rows, and 2 more variables: country <chr>, ## # ip_id <dbl> ``` ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% * summarise(num_downloads = n()) ``` ]] .column[.content[ ``` ## # A tibble: 13,272 x 2 ## package num_downloads ## <chr> <int> ## 1 A3 30 ## 2 abbyyR 20 ## 3 abc 51 ## 4 abc.data 48 ## 5 ABC.RAP 9 ## 6 ABCanalysis 10 ## 7 abcdeFBA 9 ## 8 ABCExtremes 1 ## 9 ABCoptim 15 ## 10 ABCp2 11 ## # … with 13,262 more rows ``` ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% * right_join(core_w_hex_sticker) ``` ]] .column[.content[ ``` ## # A tibble: 9 x 3 ## package num_downloads hex ## <chr> <int> <list> ## 1 ggplot2 23622 <magck-mg> ## 2 dplyr 19116 <magck-mg> ## 3 tidyr 11450 <magck-mg> ## 4 readr 12388 <magck-mg> ## 5 purrr 15070 <magck-mg> ## 6 tibble 21043 <magck-mg> ## 7 stringr 22257 <magck-mg> ## 8 forcats 9005 <magck-mg> ## 9 tidyverse 7129 <magck-mg> ``` ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% *ggplot() ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + * aes(x = reorder(x = package, X = -num_downloads)) ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + *# each sticker represents many downloads * aes(y = round(num_downloads / 4000, 0)) ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + * aes(image = hex) # hex column is list! ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! *# a column filled with the image * ggtextures::geom_isotype_col() ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! # a column filled with the image ggtextures::geom_isotype_col() + * labs(title = "Number of core tidyverse packages downloaded Sept 10, 2018") ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! # a column filled with the image ggtextures::geom_isotype_col() + labs(title = "Number of core tidyverse packages downloaded Sept 10, 2018") + * labs(subtitle = "Each icon represents 4000 downloads, rounding to nearest 4000\nData: cran-logs.rstudio.com") ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! # a column filled with the image ggtextures::geom_isotype_col() + labs(title = "Number of core tidyverse packages downloaded Sept 10, 2018") + labs(subtitle = "Each icon represents 4000 downloads, rounding to nearest 4000\nData: cran-logs.rstudio.com") + * labs(caption = "Vis: Gina Reynolds for #TidyTuesday w/ ggtextures") ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! # a column filled with the image ggtextures::geom_isotype_col() + labs(title = "Number of core tidyverse packages downloaded Sept 10, 2018") + labs(subtitle = "Each icon represents 4000 downloads, rounding to nearest 4000\nData: cran-logs.rstudio.com") + labs(caption = "Vis: Gina Reynolds for #TidyTuesday w/ ggtextures") + * theme_void(base_family = "") ``` ]] .column[.content[ <!-- --> ]] --- class: split-40 count: false .column[.content[ ```r package_download_2018_09_10 %>% group_by(package) %>% summarise(num_downloads = n()) %>% right_join(core_w_hex_sticker) %>% ggplot() + aes(x = reorder(x = package, X = -num_downloads)) + # each sticker represents many downloads aes(y = round(num_downloads / 4000, 0)) + aes(image = hex) + # hex column is list! # a column filled with the image ggtextures::geom_isotype_col() + labs(title = "Number of core tidyverse packages downloaded Sept 10, 2018") + labs(subtitle = "Each icon represents 4000 downloads, rounding to nearest 4000\nData: cran-logs.rstudio.com") + labs(caption = "Vis: Gina Reynolds for #TidyTuesday w/ ggtextures") + theme_void(base_family = "") + * theme(plot.background = * element_rect(fill = "gainsboro")) ``` ]] .column[.content[ <!-- --> ]] --- # End <style type="text/css"> .remark-code{line-height: 1.5; font-size: 70%} </style>