├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── R ├── helpers.R └── pencil-case.R ├── README.Rmd ├── README.md ├── assets ├── fonts │ ├── Cormorant Garamond │ │ ├── CormorantGaramond-Bold.ttf │ │ ├── CormorantGaramond-BoldItalic.ttf │ │ ├── CormorantGaramond-Italic.ttf │ │ ├── CormorantGaramond-Light.ttf │ │ ├── CormorantGaramond-LightItalic.ttf │ │ ├── CormorantGaramond-Medium.ttf │ │ ├── CormorantGaramond-MediumItalic.ttf │ │ ├── CormorantGaramond-Regular.ttf │ │ ├── CormorantGaramond-SemiBold.ttf │ │ ├── CormorantGaramond-SemiBoldItalic.ttf │ │ └── OFL.txt │ ├── christmas_dream.zip │ ├── christmas_dream │ │ ├── Christmas Dream.ttf │ │ └── README BEFORE INSTAL !!.txt │ ├── fifa │ │ └── qatar2022arabic-heavy.ttf │ ├── fontawesome-free-6.2.0-web │ │ ├── fa-brands-400.ttf │ │ └── fa-solid-900.ttf │ ├── metal-gothic │ │ └── MetalGothicDemoVersionRegular-WyB9A.ttf │ ├── pokemon │ │ ├── Pokemon Hollow.ttf │ │ ├── Pokemon Solid.ttf │ │ ├── pokemon.zip │ │ └── pokemon │ │ │ ├── Pokemon Hollow.ttf │ │ │ └── Pokemon Solid.ttf │ ├── simpsonfont.zip │ ├── star trek │ │ ├── TNG_Title.ttf │ │ └── jeffries.TTF │ ├── taylor-swift │ │ ├── Pistilli-Roman.otf │ │ └── Rojal.ttf │ └── the-simpsons │ │ ├── Simpsonfont DEMO.otf │ │ ├── Simpsonfont II.png │ │ ├── Simpsonfont glyph map.png │ │ └── readme.txt └── template.pptx ├── man └── hello.Rd ├── scripts ├── 2022 │ ├── week-48-FIFA-world-cup │ │ ├── FIFA-world-cup.R │ │ └── FIFA-world-cup.png │ ├── week-49-elevators │ │ ├── elevators.R │ │ └── elevators.png │ ├── week-50-retail │ │ ├── retail.R │ │ └── retail.png │ ├── week-51-weather │ │ ├── weather.R │ │ └── weather.png │ └── week-52-star-trek │ │ ├── star-trek.R │ │ └── star-trek.png ├── 2023 │ ├── week-01-BYOD │ │ ├── mischa.R │ │ ├── mischa.png │ │ ├── not voted out eliminated.png │ │ ├── not voted out med evac.png │ │ ├── not voted out quit.png │ │ ├── not voted out.png │ │ └── pantry.jpg │ ├── week-02-birds │ │ ├── birds.R │ │ └── birds.png │ ├── week-03-artists │ │ ├── artists sm-s.png │ │ ├── artists sm.png │ │ ├── artists-s.png │ │ ├── artists.R │ │ └── artists.png │ ├── week-04-alone │ │ ├── alone.R │ │ └── alone.png │ ├── week-05-cats │ │ ├── cats.R │ │ └── cats.png │ ├── week-06-tech │ │ ├── tech.R │ │ └── tech.png │ ├── week-07-hollywood │ │ ├── hollywood.R │ │ └── hollywood.png │ ├── week-08-bob-ross │ │ ├── bob ross.R │ │ └── bob-ross.png │ ├── week-09-afrisenti │ │ ├── afrisenti.R │ │ └── afrisenti.png │ ├── week-10-numbats │ │ ├── numbats.R │ │ └── numbats.png │ ├── week-11-drugs │ │ ├── drugs.R │ │ └── drugs.png │ ├── week-12-languages │ │ ├── languages.R │ │ └── languages.png │ ├── week-13-time-zones │ │ ├── time-zones-s.png │ │ ├── time-zones.png │ │ └── times-zones.R │ ├── week-14-soccer │ │ ├── logos.csv │ │ ├── soccer.R │ │ └── soccer.png │ ├── week-15-eggs │ │ ├── eggs.R │ │ └── eggs.png │ ├── week-16-crops │ │ ├── crops.R │ │ └── crops.png │ ├── week-17-london-marathon │ │ ├── london-marathon.R │ │ └── london-marathon.png │ ├── week-18-portal │ │ ├── portal.R │ │ └── portal.png │ ├── week-19-childcare │ │ ├── childcare.R │ │ └── childcare.png │ ├── week-20-tornados │ │ ├── tornados.R │ │ └── tornados.png │ ├── week-21-squirrels │ │ ├── squirrels.R │ │ └── squirrels.png │ ├── week-22-centenarians │ │ ├── centenarians.R │ │ └── centenarians.png │ ├── week-23-energy │ │ ├── energy-s.png │ │ ├── energy.R │ │ └── energy.png │ ├── week-24-safi │ │ ├── safi.R │ │ └── safi.png │ ├── week-25-ufo │ │ ├── ufo.R │ │ └── ufo.png │ ├── week-26-us-places │ │ ├── us-places.R │ │ └── us-places.png │ ├── week-27-markers │ │ ├── markers.R │ │ └── markers.png │ ├── week-28-temperatures │ │ ├── hist.png │ │ ├── nh-temperatures.png │ │ ├── sh-temperatures.png │ │ ├── temperature.R │ │ └── temperatures.png │ ├── week-29-gpt │ │ ├── gpt.R │ │ └── gpt.png │ ├── week-30-scurvy │ │ ├── scurvy-2-s.png │ │ └── scurvy-2.png │ ├── week-31-us-states │ │ ├── us-states-s.png │ │ ├── us-states.R │ │ └── us-states.png │ ├── week-32-hot-ones │ │ ├── hot-ones-s.png │ │ ├── hot-ones.R │ │ └── hot-ones.png │ ├── week-33-spam │ │ ├── spam-s.png │ │ ├── spam.R │ │ └── spam.png │ ├── week-34-refugees │ │ ├── refugees-s.png │ │ ├── refugees.R │ │ └── refugees.png │ ├── week-35-copyright │ │ ├── copyright-s.png │ │ ├── copyright.R │ │ └── copyright.png │ ├── week-36-unions │ │ ├── unions-s.png │ │ ├── unions.R │ │ └── unions.png │ ├── week-37-global-human-day │ │ ├── global-human-day-s.png │ │ ├── global-human-day.R │ │ └── global-human-day.png │ ├── week-38-cran │ │ ├── cran-s.png │ │ ├── cran.R │ │ └── cran.png │ ├── week-39-roy-kent-f-count │ │ ├── roy-kent-f-count-s.png │ │ ├── roy-kent-f-count.R │ │ └── roy-kent-f-count.png │ ├── week-40-US-grants │ │ ├── US-grants-s.png │ │ ├── us-grants.R │ │ └── us-grants.png │ ├── week-41-haunted-places │ │ ├── haunted-places-s.png │ │ ├── haunted-places.R │ │ ├── haunted-places.png │ │ └── sample.csv │ ├── week-42-taylor-swift │ │ ├── eras-tour-set-list.txt │ │ ├── taylor-swift-s.png │ │ ├── taylor-swift.R │ │ └── taylor-swift.png │ ├── week-43-patient-risk-profiles │ │ ├── patient-risk-profiles-s.png │ │ ├── patient-risk-profiles.R │ │ └── patient-risk-profiles.png │ ├── week-44-horror-articles │ │ ├── horror-articles-s.png │ │ ├── horror-articles.R │ │ ├── horror-articles.png │ │ └── three-words.rds │ ├── week-45-house │ │ ├── house-s.png │ │ ├── house.R │ │ └── house.png │ ├── week-46-diwali │ │ ├── diwali-s.png │ │ ├── diwali.R │ │ ├── diwali.png │ │ ├── legend.png │ │ └── legend1.png │ ├── week-47-rladies │ │ ├── rladies-s.png │ │ ├── rladies.R │ │ └── rladies.png │ ├── week-48-dr-who │ │ ├── dr-who-s.png │ │ ├── dr-who.R │ │ └── dr-who.png │ ├── week-49-life-expectancy │ │ ├── life-expectancy-aus-s.png │ │ ├── life-expectancy-aus.png │ │ ├── life-expectancy-s.png │ │ ├── life-expectancy.R │ │ └── life-expectancy.png │ ├── week-49-traffic │ │ ├── traffic-s.png │ │ └── traffic.png │ ├── week-50-christmas-movies │ │ ├── christmas-movies-s.png │ │ ├── christmas-movies.R │ │ └── christmas-movies.png │ ├── week-51-holiday-episodes │ │ ├── holiday-episodes-s.png │ │ ├── holiday-episodes.R │ │ └── holiday-episodes.png │ └── week-52-cran │ │ ├── cran-s.png │ │ ├── cran.R │ │ └── cran.png ├── 2024 │ ├── week-48-border-control │ │ ├── border-control-final.png │ │ ├── border-control.R │ │ └── border-control.png │ ├── week-49-traffic │ │ ├── traffic-final.pdf │ │ ├── traffic-final.png │ │ ├── traffic.R │ │ ├── traffic.png │ │ └── traffic.pptx │ └── week-50-perfume │ │ ├── bottle-image.png │ │ ├── brands.png │ │ ├── perfume-final.png │ │ ├── perfume.R │ │ ├── perfume.png │ │ ├── perfume.pptx │ │ └── words.png ├── 2025 │ ├── 01 - BYOD │ │ ├── predator-s.jpg │ │ └── predator.jpg │ ├── 02 - posit-conf │ │ ├── posit-conf-s.png │ │ ├── posit-conf.R │ │ └── posit-conf.png │ ├── 03 - himalaya │ │ ├── himalaya final-s.png │ │ ├── himalaya final.png │ │ ├── himalaya template.pptx │ │ ├── himalaya.R │ │ └── himalaya.png │ ├── 04 - water security │ │ ├── water security-s.png │ │ ├── water security.png │ │ └── water-security.R │ ├── 05 - simpsons │ │ ├── simpsons-s.png │ │ ├── simpsons.R │ │ └── simpsons.png │ ├── 06 - cdc-datasets │ │ ├── cdc-datasets-s.png │ │ ├── cdc-datasets.R │ │ └── cdc-datasets.png │ ├── 07 - agencies │ │ ├── agencies-s.png │ │ ├── agencies.R │ │ └── agencies.png │ ├── 08 - academic literature │ │ ├── academic-s.png │ │ ├── academic.R │ │ └── academic.png │ ├── 09 - long beach │ │ ├── long beach-s.png │ │ ├── long beach.R │ │ └── long beach.png │ ├── 10 - pixar │ │ ├── pixar-s.png │ │ ├── pixar.R │ │ └── pixar.png │ ├── 11-palm trees │ │ ├── palm-trees-gross-s.png │ │ ├── palm-trees-gross.png │ │ ├── palm-trees-s.png │ │ ├── palm-trees.R │ │ └── palm-trees.png │ ├── 12 - amazon │ │ ├── amazon-s.png │ │ ├── amazon.R │ │ └── amazon.png │ ├── 13 - pokemon │ │ ├── pokemon-s.png │ │ ├── pokemon-stats.png │ │ ├── pokemon-title.png │ │ ├── pokemon.R │ │ └── pokemon.png │ ├── 14 - timely and effective care │ │ ├── care-s.png │ │ ├── care.R │ │ └── care.png │ ├── 15 - penguins │ │ ├── penguins-s.png │ │ ├── penguins.R │ │ └── penguins.png │ ├── 16 - road fatalities │ │ ├── road fatalities-s.png │ │ ├── road fatalities.R │ │ └── road fatalities.png │ └── 19 - mount vesuvius │ │ ├── mount vesuvius-s.png │ │ ├── mount vesuvius.R │ │ └── mount vesuvius.png └── visit-sim.R ├── style.css └── tidytues.Rproj /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | scripts 4 | assets 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | scripts/2023/week 4 alone/images 6 | scripts/2023/week-21-squirrels/images 7 | scripts/2023/week-30-scurvy/photorealistic/ 8 | scripts/dev 9 | images 10 | scripts/2023/week-41-haunted-places/DALL-E 11 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: tidytues 2 | Type: Package 3 | Title: What the Package Does (Title Case) 4 | Version: 0.1.0 5 | Author: Who wrote it 6 | Maintainer: The package maintainer 7 | Description: More about what it does (maybe more than one line) 8 | Use four spaces when indenting paragraphs within the Description. 9 | License: What license is it under? 10 | Encoding: UTF-8 11 | LazyData: true 12 | -------------------------------------------------------------------------------- /R/pencil-case.R: -------------------------------------------------------------------------------- 1 | #' @export 2 | pencil_case <- list( 3 | pal1 = c('#4a166a', '#ce5068', '#f0d35b', '#61aa6f', "#2f3c68") 4 | ) 5 | -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-Bold.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-BoldItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-Italic.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-Light.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-LightItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-Medium.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-MediumItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-Regular.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-SemiBold.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/CormorantGaramond-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/Cormorant Garamond/CormorantGaramond-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Cormorant Garamond/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2015 the Cormorant Project Authors (github.com/CatharsisFonts/Cormorant) 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /assets/fonts/christmas_dream.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/christmas_dream.zip -------------------------------------------------------------------------------- /assets/fonts/christmas_dream/Christmas Dream.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/christmas_dream/Christmas Dream.ttf -------------------------------------------------------------------------------- /assets/fonts/christmas_dream/README BEFORE INSTAL !!.txt: -------------------------------------------------------------------------------- 1 | ATTENTION !! 2 | 3 | By downloading and installing this font, you are agree that the only font you install and you download is the "FOR PERSONAL USE" font that is "Non-Commercial". 4 | And if you use the font on a "Commercial", there will be consequences for paying according to the license you are using. 5 | 6 | 7 | Full License Here : 8 | https://www.creativefabrica.com/product/christmas-dream-3/ref/379016/ 9 | https://creativemarket.com/HATFSTUDIO/91583117-Christmas-Dream 10 | 11 | For Donation Paypal : hatftype@gmail.com 12 | 13 | 1. This font is ONLY FOR PERSONAL USE. 14 | 2. NO COMMERCIAL USE ALLOWED. 15 | 3. You are REQUIRES A LICENSE for PROMOTIONAL or COMMERCIAL USE. 16 | 4. CONTACT ME before any Promotional or Commercial Use. 17 | 18 | 19 | Support email: 20 | hatftype@gmail.com 21 | 22 | Thanks -------------------------------------------------------------------------------- /assets/fonts/fifa/qatar2022arabic-heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/fifa/qatar2022arabic-heavy.ttf -------------------------------------------------------------------------------- /assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf -------------------------------------------------------------------------------- /assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf -------------------------------------------------------------------------------- /assets/fonts/metal-gothic/MetalGothicDemoVersionRegular-WyB9A.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/metal-gothic/MetalGothicDemoVersionRegular-WyB9A.ttf -------------------------------------------------------------------------------- /assets/fonts/pokemon/Pokemon Hollow.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/pokemon/Pokemon Hollow.ttf -------------------------------------------------------------------------------- /assets/fonts/pokemon/Pokemon Solid.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/pokemon/Pokemon Solid.ttf -------------------------------------------------------------------------------- /assets/fonts/pokemon/pokemon.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/pokemon/pokemon.zip -------------------------------------------------------------------------------- /assets/fonts/pokemon/pokemon/Pokemon Hollow.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/pokemon/pokemon/Pokemon Hollow.ttf -------------------------------------------------------------------------------- /assets/fonts/pokemon/pokemon/Pokemon Solid.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/pokemon/pokemon/Pokemon Solid.ttf -------------------------------------------------------------------------------- /assets/fonts/simpsonfont.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/simpsonfont.zip -------------------------------------------------------------------------------- /assets/fonts/star trek/TNG_Title.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/star trek/TNG_Title.ttf -------------------------------------------------------------------------------- /assets/fonts/star trek/jeffries.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/star trek/jeffries.TTF -------------------------------------------------------------------------------- /assets/fonts/taylor-swift/Pistilli-Roman.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/taylor-swift/Pistilli-Roman.otf -------------------------------------------------------------------------------- /assets/fonts/taylor-swift/Rojal.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/taylor-swift/Rojal.ttf -------------------------------------------------------------------------------- /assets/fonts/the-simpsons/Simpsonfont DEMO.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/the-simpsons/Simpsonfont DEMO.otf -------------------------------------------------------------------------------- /assets/fonts/the-simpsons/Simpsonfont II.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/the-simpsons/Simpsonfont II.png -------------------------------------------------------------------------------- /assets/fonts/the-simpsons/Simpsonfont glyph map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/fonts/the-simpsons/Simpsonfont glyph map.png -------------------------------------------------------------------------------- /assets/fonts/the-simpsons/readme.txt: -------------------------------------------------------------------------------- 1 | OTF: Simpsonfont 2 | Dennis Ludlow 2017 all rights reserved 3 | by Sharkshock 4 | dennis@sharkshock.net 5 | 6 | Cowabunga font lovers! After 10+ years this old classic gets a serious facelift. Changes were made to smoothen out the curves and make them appear more "ink" like. This update features 7 | completely redrawn glyphs, kerning, basic/extended latin, European accents, and Cyrillic characters. Use Simpsonfont in a poster, game, or kid's book. The demo version features 8 | basic latin, numbers, limited punctuation, and limited kerning. 9 | 10 | Complete regular version is available with purchase of commercial license or $25 payment via PayPal. Please note that this $25 is for PERSONAL use only and does not constitute a 11 | commercial license. 12 | 13 | This font like my others are free for personal use only as long as this readme file stays intact. For commercial use please contact me at dennis@sharkshock.net to discuss an end user license agreement. You can also visit www.sharkshock.net/license for more info and terms. I also design custom 14 | fonts for companies, logos, and many other things. If you'd like to leave me a PayPal donation you can use my email address above. Your generosity will be most appreciated! 15 | 16 | Thank you for your support! 17 | 18 | visit www.sharkshock.net for more and take a bite out of BORING design! 19 | 20 | tags: children, kids, sans, sans serif, cartoon, sloppy, handwriting, handwritten, Simpsons, abstract, Homer, publishing, project, scrapbook, sharkshock, latin, Russian, Ukranian, 21 | childrens, child, book, display, logo, show, tv, movies, media 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /assets/template.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/assets/template.pptx -------------------------------------------------------------------------------- /man/hello.Rd: -------------------------------------------------------------------------------- 1 | \name{hello} 2 | \alias{hello} 3 | \title{Hello, World!} 4 | \usage{ 5 | hello() 6 | } 7 | \description{ 8 | Prints 'Hello, world!'. 9 | } 10 | \examples{ 11 | hello() 12 | } 13 | -------------------------------------------------------------------------------- /scripts/2022/week-48-FIFA-world-cup/FIFA-world-cup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2022/week-48-FIFA-world-cup/FIFA-world-cup.png -------------------------------------------------------------------------------- /scripts/2022/week-49-elevators/elevators.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2022/week-49-elevators/elevators.png -------------------------------------------------------------------------------- /scripts/2022/week-50-retail/retail.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(lubridate) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2022, week = 50) 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | pal <- colorRampPalette(c('#173f5f', '#20639b', '#3caea3', '#f6d55c', '#ed553b'))(11) 18 | 19 | txt <- "grey20" 20 | bg <- "white" 21 | line = "grey80" 22 | 23 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 25 | font_add_google("Kanit", "mukta") 26 | showtext_auto() 27 | 28 | ft <- "mukta" 29 | 30 | # 🤼 wrangle ----------------------------------------------------------------- 31 | 32 | # 🔡 text -------------------------------------------------------------------- 33 | 34 | mastodon <- glue("") 35 | twitter <- glue("") 36 | github <- glue("") 37 | floppy <- glue("") 38 | space <- glue("'") 39 | caption <- glue("{mastodon} @danoehm@{space}fosstodon.org
{twitter} @danoehm
{github} doehm/tidytues
{floppy} US Census Bureau Monthly State Retails Sales") 40 | 41 | # 📊 plot -------------------------------------------------------------------- 42 | 43 | dat$state_retail |> 44 | filter( 45 | state_abbr == "USA", 46 | subsector != "total" 47 | ) |> 48 | mutate( 49 | ym = ymd(paste0(year, "-", month, "-01")), 50 | change_yoy = as.numeric(change_yoy), 51 | change_yoy_se = as.numeric(change_yoy_se) 52 | ) |> 53 | group_by(subsector) |> 54 | mutate(max = max(change_yoy)) |> 55 | ggplot(aes(ym, change_yoy, colour = max, fill = max)) + 56 | geom_area() + 57 | geom_text(aes(ymd("2020-01-01"), 600, label = str_wrap(subsector, 12)), family = ft, size = 24, lineheight = 0.3, vjust = 1, colour = txt) + 58 | facet_wrap(~subsector, ncol = 2)+ 59 | scale_colour_gradientn(colours = pal) + 60 | scale_fill_gradientn(colours = pal) + 61 | labs( 62 | caption = caption, 63 | title = "US Monthly Retail Sales", 64 | subtitle = "Percentage change year on year
65 | There was a 7 fold increase in clothing sales in 2021", 66 | ) + 67 | theme_void() + 68 | theme( 69 | text = element_text(family = ft, size = 48, colour = txt, lineheight = 0.3), 70 | plot.background = element_rect(fill = bg), 71 | plot.caption = element_markdown(family = ft, size = 48, colour = txt, hjust = 0, lineheight = 0.3), 72 | plot.title = element_text(family = ft, size = 128, colour = txt, hjust = 0.2, face = "bold"), 73 | plot.subtitle = element_markdown(family = ft, size = 48, colour = txt, hjust = 0.15, margin = margin(b = 20), halign = 0), 74 | plot.margin = margin(b = 20, t = 30, r = 50, l = 50), 75 | strip.text = element_blank(), 76 | legend.position = "none", 77 | axis.text = element_text(margin = margin(t = 10, b = 10, l = 10, r = 10)), 78 | axis.ticks = element_line(colour = line), 79 | axis.line = element_line(colour = line), 80 | panel.grid = element_line(colour = line, linetype = 3) 81 | ) 82 | 83 | ggsave("scripts/2022/week 50 retail/retail.png", height = 16, width = 10) 84 | -------------------------------------------------------------------------------- /scripts/2022/week-50-retail/retail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2022/week-50-retail/retail.png -------------------------------------------------------------------------------- /scripts/2022/week-51-weather/weather.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2022/week-51-weather/weather.png -------------------------------------------------------------------------------- /scripts/2022/week-52-star-trek/star-trek.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(janitor) 6 | library(glue) 7 | library(ggtext) 8 | 9 | # 💾 load data --------------------------------------------------------------- 10 | 11 | dat <- tidytuesdayR::tt_load(2022, week = 52) 12 | attach(dat) 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | txt <- "white" 17 | txt2 <- pal[1] 18 | bg <- "grey10" 19 | 20 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 21 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 22 | font_add("trek", regular = "assets/fonts/star trek/TNG_Title.ttf") 23 | font_add("jeff", regular = "assets/fonts/star trek/jeffries.ttf") 24 | font_add_google("Mukta", "mukta") 25 | showtext_auto() 26 | 27 | ft <- "mukta" 28 | ft2 <- "jeff" 29 | 30 | pal <- c('#d7ad19', '#be293d', '#019dcd') 31 | 32 | # 🤼 wrangle ----------------------------------------------------------------- 33 | 34 | df_base <- tlBooks |> 35 | count(year) |> 36 | filter( 37 | year > 0, 38 | year < 3000 39 | ) |> 40 | mutate(alpha = n/max(n)) 41 | 42 | # 🔡 text -------------------------------------------------------------------- 43 | 44 | mastodon <- glue("") 45 | twitter <- glue("") 46 | github <- glue("") 47 | floppy <- glue("") 48 | space <- glue("'") 49 | spock <- glue("") 50 | caption <- glue("{mastodon} @danoehm@{space}fosstodon.org • {twitter} @danoehm • {github} doehm/tidytues • {floppy} rtrek package") 51 | 52 | subtitle <- glue( 53 | "Almost 60% (1252/2122) of Star Trek narratives
54 | across all formats occur between the years
55 | 2351 and 2380 {spock}") 56 | 57 | # 📊 plot -------------------------------------------------------------------- 58 | 59 | df_base |> 60 | ggplot() + 61 | geom_segment(aes(x = year, xend = year, y = 0, yend = n), colour = txt) + 62 | geom_segment(aes(x = year, xend = year, y = 0, yend = 159, alpha = alpha), colour = txt) + 63 | annotate("text", x=0, y=159, label = "STAR TREK", colour = pal[3], family = "trek", size = 164, hjust = 0, vjust = 1) + 64 | annotate("richtext", x=0, y=130, label = subtitle, colour = pal[1], family = ft2, size = 16, hjust = 0, vjust = 1, 65 | lineheight = 0.6, label.color = NA, fill = NA) + 66 | scale_x_continuous(breaks = seq(0, 3000, 1000), labels = seq(0, 3000, 1000)) + 67 | scale_alpha_identity() + 68 | labs(caption = caption) + 69 | theme_void() + 70 | theme( 71 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 72 | plot.background = element_rect(fill = bg), 73 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t=20)), 74 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 75 | axis.text.x = element_text() 76 | ) 77 | 78 | ggsave("scripts/2022/week 52 star trek/star trek.png", height = 12, width = 16) 79 | -------------------------------------------------------------------------------- /scripts/2022/week-52-star-trek/star-trek.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2022/week-52-star-trek/star-trek.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/mischa.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(glue) 6 | library(ggtext) 7 | library(lubridate) 8 | library(ggpubr) 9 | library(magick) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | pantry <- image_read("scripts/2023/week 1 BYOD/pantry.jpg") 14 | pantry_blurred <- image_blur(pantry, 25, 30) 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "grey20" 19 | bg <- "white" 20 | 21 | pal1 <- colorRampPalette(c('#91A0B2', '#6C6C6D', "white"))(16) 22 | 23 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 25 | font_add_google("Covered By Your Grace", "grace") 26 | font_add_google("Rock Salt", "salt") 27 | showtext_auto() 28 | 29 | ft <- "grace" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df_mischa <- tribble( 34 | ~date, ~height, 35 | "2020-11-04", 50, 36 | "2021-11-04", 73, 37 | "2022-01-07", 77, 38 | "2022-03-11", 78, 39 | "2022-05-08", 81, 40 | "2022-08-21", 83, 41 | "2022-11-04", 84 42 | ) |> 43 | mutate( 44 | date = ymd(date), 45 | date_lab = paste0(round(height),"cm ", format(date, "%d %b %Y")) 46 | ) 47 | 48 | # 🔡 text -------------------------------------------------------------------- 49 | 50 | mastodon <- glue("") 51 | twitter <- glue("") 52 | github <- glue("") 53 | floppy <- glue("") 54 | space <- glue("'") 55 | caption <- glue( 56 | "{mastodon} @danoehm@{space}fosstodon.org
57 | {github} doehm/tidytues
58 | {floppy} The pantry
59 | {twitter} @danoehm") 60 | 61 | # 📊 plot -------------------------------------------------------------------- 62 | 63 | a <- -10 64 | 65 | df_mischa |> 66 | ggplot() + 67 | background_image(pantry_blurred) + 68 | geom_rect(aes(xmin = -2, xmax = 5, ymin = 0, ymax = 90), fill = pal1[13]) + 69 | geom_rect(aes(xmin = -1.9, xmax = -0.3, ymin = 0, ymax = 90), fill = pal1[12]) + 70 | geom_rect(aes(xmin = -0.3, xmax = -0.18, ymin = 0, ymax = 90), fill = pal1[10]) + 71 | geom_rect(aes(xmin = -1.9, xmax = 5, ymin = 0, ymax = 8), fill = pal1[12]) + 72 | geom_segment(aes(x = -0.3, xend = -0.3, y = 0, yend = 8), colour = pal1[10]) + 73 | geom_segment(aes(x = -0.3, xend = 5, y = 8, yend = 8), colour = pal1[11], size = 1) + 74 | geom_segment(aes(x = 0, xend = 1, y = height, yend = height), colour = txt) + 75 | geom_text(aes(x = 1.25, y = height, label = date_lab), family = ft, colour = txt, size = 20, hjust = 0) + 76 | annotate("text", x = 0.4, y = 13, label = "MISCHA", family = "salt", size = 40, 77 | lineheight = 0.32, colour = txt, hjust = 0, fontface = "bold") + 78 | annotate("richtext", x = 4.8, y = 4, label = caption, family = ft, size = 16, 79 | lineheight = 0.28, colour = txt, hjust = 1, label.color = NA, fill = NA) + 80 | xlim(-5, 5) + 81 | ylim(0, 90) + 82 | theme_void() + 83 | theme( 84 | text = element_text(family = ft, colour = txt, size = 48), 85 | plot.background = element_rect(fill = bg, colour = bg), 86 | plot.caption = element_markdown(hjust = 0.5), 87 | plot.title = element_text(family = ft, size = 128, hjust = 0.5, face = "bold"), 88 | plot.subtitle = element_text(family = ft, size = 48, colour = txt, hjust = 0.5), 89 | plot.margin = margin(b = a, t = a, r = a, l = a) 90 | ) 91 | 92 | ggsave("2023/week 1 BYOD/mischa.png", height = 16, width = 8) 93 | 94 | -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/mischa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/mischa.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/not voted out eliminated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/not voted out eliminated.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/not voted out med evac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/not voted out med evac.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/not voted out quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/not voted out quit.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/not voted out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/not voted out.png -------------------------------------------------------------------------------- /scripts/2023/week-01-BYOD/pantry.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-01-BYOD/pantry.jpg -------------------------------------------------------------------------------- /scripts/2023/week-02-birds/birds.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(janitor) 6 | library(glue) 7 | library(ggtext) 8 | library(colorspace) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 2) 13 | df1 <- dat$PFW_2021_public 14 | df2 <- dat$PFW_count_site_data_public_2021 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | pal <- c('#64312e', '#d95232', '#f19540', '#e3db9a', '#c2aa3e', '#545432', '#193536') 19 | bg <- "white" 20 | txt <- '#64312e' 21 | 22 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 24 | font_add_google("Mukta", "mukta") 25 | font_add_google("Rowdies", "rowdies") 26 | showtext_auto() 27 | 28 | ft <- "mukta" 29 | ft_title <- "rowdies" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df_birds <- df1 |> 34 | group_by(loc_id, subnational1_code, latitude, longitude) |> 35 | summarise(n_birds = sum(how_many, na.rm = TRUE)) 36 | 37 | df_base <- df_birds |> 38 | separate(subnational1_code, into = c("country", "state"), sep = "-") |> 39 | filter(state == "WA") 40 | 41 | df_map <- map("county", plot = FALSE, fill = TRUE) %>% 42 | st_as_sf() %>% 43 | filter(str_sub(ID, 1, 10) == "washington") 44 | 45 | # 🔡 text -------------------------------------------------------------------- 46 | 47 | mastodon <- glue("") 48 | twitter <- glue("") 49 | github <- glue("") 50 | floppy <- glue("") 51 | space <- glue("'") 52 | caption <- glue("{mastodon} @danoehm@{space}fosstodon.org • {twitter} @danoehm • {github} doehm/tidytuesday • {floppy} Project FeederWatch") 53 | 54 | # 📊 plot -------------------------------------------------------------------- 55 | 56 | df_base |> 57 | ggplot() + 58 | geom_sf(data = df_map, fill = lighten(pal[7], 0.5), colour = bg) + 59 | geom_point(aes(longitude, latitude, size = n_birds), colour = pal[1], alpha = 0.75) + 60 | labs( 61 | title = "Project FeederWatch", 62 | subtitle = "Bird sightings in Washington state", 63 | caption = caption, 64 | size = "Number\nof birds" 65 | ) + 66 | theme_void() + 67 | theme( 68 | text = element_text(size = 48, colour = txt, lineheight = 0.3, family = ft), 69 | plot.title = element_text(family = ft_title, size = 160, hjust = 0.5, margin = margin(b = 20)), 70 | plot.subtitle = element_text(family = ft, hjust = 0.5, margin = margin(b = 60)), 71 | plot.background = element_rect(fill = bg, colour = NA), 72 | plot.caption = element_markdown(hjust = 0.5, margin = margin(t = 50, b = -100)), 73 | plot.margin = margin(l = 30, r = 30), 74 | legend.position = "bottom" 75 | ) 76 | 77 | ggsave("scripts/2023/week 2 birds/birds.png", height = 12, width = 12) 78 | -------------------------------------------------------------------------------- /scripts/2023/week-02-birds/birds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-02-birds/birds.png -------------------------------------------------------------------------------- /scripts/2023/week-03-artists/artists sm-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-03-artists/artists sm-s.png -------------------------------------------------------------------------------- /scripts/2023/week-03-artists/artists sm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-03-artists/artists sm.png -------------------------------------------------------------------------------- /scripts/2023/week-03-artists/artists-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-03-artists/artists-s.png -------------------------------------------------------------------------------- /scripts/2023/week-03-artists/artists.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(forcats) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 3) 14 | artists <- dat$artists 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | bg <- "black" 19 | txt <- "grey50" 20 | pal <- c("pink", "grey50", "grey50") 21 | 22 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 24 | font_add_google("Mukta", "mukta") 25 | showtext_auto() 26 | 27 | ft <- "mukta" 28 | 29 | # 🤼 wrangle ----------------------------------------------------------------- 30 | 31 | df_base <- artists |> 32 | filter(artist_gender %in% c("Male", "Female")) |> 33 | group_by(edition_number, artist_name, artist_gender) |> 34 | summarise(r = mean(space_ratio_per_page_total), .groups = "drop") |> 35 | mutate( 36 | artist_name = str_sub(artist_name, 1, 40), 37 | artist_name = fct_reorder(artist_name, r, max), 38 | x = ifelse(artist_gender == "Female", edition_number + 19, edition_number) 39 | ) 40 | 41 | df_gender <- df_base |> 42 | group_by(artist_gender) |> 43 | summarise( 44 | r = sum(r), 45 | n = n_distinct(artist_name), 46 | x = mean(x) 47 | ) |> 48 | ungroup() |> 49 | mutate( 50 | pr = paste0(round(r/sum(r), 2)*100, "%"), 51 | pn = round(n/sum(n), 2)*100, 52 | lab = paste(n, artist_gender, "artists /", pr, "coverage") 53 | ) 54 | 55 | # 🔡 text -------------------------------------------------------------------- 56 | 57 | mastodon <- glue("") 58 | twitter <- glue("") 59 | github <- glue("") 60 | floppy <- glue("") 61 | space <- glue("'") 62 | caption <- glue("{mastodon} @danoehm@{space}fosstodon.org • {twitter} @danoehm • {github} doehm/tidytuesday • {floppy} arthistory data package") 63 | 64 | # 📊 plot -------------------------------------------------------------------- 65 | 66 | df_base |> 67 | ggplot(aes(x, artist_name, size = 4*r, colour = artist_gender)) + 68 | geom_text(aes(19, artist_name, label = artist_name), size = 6, family = ft) + 69 | geom_text(aes(x, -10, label = lab), df_gender, family = ft, size = 32) + 70 | geom_jitter() + 71 | scale_size_identity() + 72 | scale_colour_manual(values = pal) + 73 | labs(caption = caption) + 74 | coord_cartesian(clip = "off") + 75 | theme_void() + 76 | theme( 77 | text = element_text(family = ft, size = 24, lineheight = 0.3, colour = txt), 78 | plot.background = element_rect(fill = bg), 79 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t=80), size = 32), 80 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 81 | legend.position = "none", 82 | ) 83 | 84 | ggsave("scripts/2023/week 3 artists/artists.png", height = 48, width = 30) 85 | ggsave("scripts/2023/week 3 artists/artists sm.png", height = 24, width = 15) 86 | -------------------------------------------------------------------------------- /scripts/2023/week-03-artists/artists.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-03-artists/artists.png -------------------------------------------------------------------------------- /scripts/2023/week-04-alone/alone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-04-alone/alone.png -------------------------------------------------------------------------------- /scripts/2023/week-05-cats/cats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-05-cats/cats.png -------------------------------------------------------------------------------- /scripts/2023/week-06-tech/tech.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | big_tech_stock_prices <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_stock_prices.csv') 13 | big_tech_companies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_companies.csv') 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | txt <- "white" 18 | bg <- "black" 19 | 20 | pal <- c( 21 | TSLA = "#e82127", 22 | MSFT = "#00a1f1", 23 | AAPL = "#555555", 24 | ADBE = "#ED2224", 25 | AMZN = "#FF9900", 26 | CSCO = "#15495d", 27 | GOOGL = "#3cba54", 28 | IBM = "#006699", 29 | INTC = "#0071c5", 30 | META = "#0668E1", 31 | NFLX = "#E50914", 32 | NVDA = "#76b900", 33 | ORCL = "#f80000" 34 | ) 35 | 36 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 37 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 38 | font_add_google("Barlow", "bar") 39 | showtext_auto() 40 | 41 | ft <- "bar" 42 | 43 | # 🤼 wrangle ----------------------------------------------------------------- 44 | 45 | df_base <- map_dfr(unique(big_tech_stock_prices$stock_symbol), ~{ 46 | big_tech_stock_prices |> 47 | mutate( 48 | group = stock_symbol, 49 | stock_symbol = .x 50 | ) 51 | }) |> 52 | left_join(big_tech_companies, by = "stock_symbol") 53 | 54 | # 🔡 text -------------------------------------------------------------------- 55 | 56 | mastodon <- glue("") 57 | twitter <- glue("") 58 | github <- glue("") 59 | floppy <- glue("") 60 | space <- glue("'") 61 | caption <- glue("{mastodon} @danoehm@{space}fosstodon.org • {twitter} @danoehm • {github} doehm/tidytuesday • {floppy} Big Tech Stock Prices on Kaggle") 62 | 63 | # 📊 plot -------------------------------------------------------------------- 64 | 65 | df_base |> 66 | ggplot() + 67 | geom_line(aes(date, close, group = group), alpha = 0.5, size = 0.1, colour = "grey") + 68 | geom_area(aes(date, close, colour = stock_symbol, fill = stock_symbol), big_tech_stock_prices, alpha = 0.2, size = 0.5) + 69 | geom_text(aes(lubridate::ymd("2011-01-01"), 500, label = str_wrap(company, 20), colour = stock_symbol), big_tech_companies, 70 | family = ft, size = 16, hjust = 0, vjust = 1, lineheight = 0.3, fontface = "bold") + 71 | facet_wrap(~stock_symbol, ncol = 3) + 72 | scale_colour_manual(values = pal) + 73 | scale_fill_manual(values = pal) + 74 | labs( 75 | title = "Big Tech Stock Prices", 76 | caption = caption 77 | ) + 78 | theme_void() + 79 | theme( 80 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = "white"), 81 | plot.background = element_rect(fill = bg, colour = bg), 82 | plot.title = element_text(size = 84, hjust = 0.5, margin = margin(b = 20), face = "bold"), 83 | plot.caption = element_markdown(hjust = 0.5, margin = margin(t=20), size = 32), 84 | plot.margin = margin(b = 20, t = 20, r = 50, l = 50), 85 | axis.text = element_text(size = 24), 86 | strip.text = element_blank(), 87 | legend.position = "none" 88 | ) 89 | 90 | ggsave("scripts/2023/week 6 tech/tech.png", height = 12, width = 12) 91 | -------------------------------------------------------------------------------- /scripts/2023/week-06-tech/tech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-06-tech/tech.png -------------------------------------------------------------------------------- /scripts/2023/week-07-hollywood/hollywood.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-07-hollywood/hollywood.png -------------------------------------------------------------------------------- /scripts/2023/week-08-bob-ross/bob ross.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(janitor) 6 | library(glue) 7 | library(ggtext) 8 | library(cropcircles) 9 | library(ggpath) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 8) 14 | 15 | bob_ross <- dat$bob_ross |> 16 | clean_names() 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | txt <- "grey20" 21 | bg <- "white" 22 | 23 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 25 | font_add_google("Mukta", "mukta") 26 | font_add_google("Satisfy", "sat") 27 | showtext_auto() 28 | 29 | ft <- "mukta" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | luminocity <- map_dbl(bob_ross$img_src, ~{ 34 | x <- image_read(.x) |> 35 | image_data() 36 | 0.2126*mean(as.numeric(x[1,,])) + 0.7152*mean(as.numeric(x[2,,])) + 0.0722*mean(as.numeric(x[3,,])) 37 | }) 38 | 39 | bob_ross <- bob_ross |> 40 | mutate(luminocity = luminocity) |> 41 | arrange(luminocity) 42 | 43 | hex_imgs <- hex_crop(bob_ross$img_src, border_size = 16, border_colour = "black") 44 | 45 | n_col <- 15 46 | n_row <- 26 47 | n <- n_col*n_row 48 | df_grid <- expand_grid( 49 | y = 0:(n_col-1), 50 | x = 0:(n_row-1) 51 | ) |> 52 | mutate( 53 | x = ifelse(y %% 2 == 1, x + cos(pi/3), x), 54 | y = y*sin(pi/3), 55 | painting = hex_imgs[1:n] 56 | ) 57 | 58 | # 🔡 text -------------------------------------------------------------------- 59 | 60 | mastodon <- glue("") 61 | twitter <- glue("") 62 | github <- glue("") 63 | floppy <- glue("") 64 | space <- glue("'") 65 | space2 <- glue("--") # can't believe I'm doing this 66 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytuesday{space2}{floppy}{space2}Bob Ross Paintings data") 67 | 68 | # 📊 plot -------------------------------------------------------------------- 69 | 70 | df_grid |> 71 | ggplot() + 72 | geom_from_path(aes(x, y, path = painting), width = 0.05) + 73 | labs( 74 | caption = caption, 75 | title = "Bob Ross" 76 | ) + 77 | coord_fixed() + 78 | theme_void() + 79 | theme( 80 | text = element_text(family = ft, size = 62, lineheight = 0.3, colour = txt), 81 | plot.background = element_rect(fill = bg, colour = bg), 82 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 83 | plot.title = element_text(family = "sat", size = 300, margin = margin(b = 10), hjust = 0.5), 84 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50) 85 | ) 86 | 87 | ggsave("scripts/2023/week 8 bob ross/bob-ross.png", height = n_row, width = n_col+1) 88 | -------------------------------------------------------------------------------- /scripts/2023/week-08-bob-ross/bob-ross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-08-bob-ross/bob-ross.png -------------------------------------------------------------------------------- /scripts/2023/week-09-afrisenti/afrisenti.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(gggibbous) 10 | library(forcats) 11 | 12 | # 💾 load data --------------------------------------------------------------- 13 | 14 | dat <- tidytuesdayR::tt_load(2023, week = 9) 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "grey20" 19 | bg <- "grey80" 20 | accent <- "#15616d" 21 | 22 | pal <- c(Positive = "#15616d", Neutral = "grey50", Negative = "#ff7d00") 23 | 24 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 25 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 26 | font_add_google("Mukta", "mukta") 27 | showtext_auto() 28 | 29 | ft <- "mukta" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df_base <- dat$afrisenti |> 34 | left_join(dat$language_countries) |> 35 | count(country, label) |> 36 | mutate( 37 | country = factor(country), 38 | label = snakecase::to_title_case(label), 39 | label = factor(label, level = c("Positive", "Neutral", "Negative")), 40 | sort_id = 3-as.numeric(label) 41 | ) |> 42 | arrange(country, sort_id) |> 43 | group_by(country) |> 44 | mutate( 45 | p = n/sum(n), 46 | cm = cumsum(p), 47 | # cm0 = 1-cm, 48 | y_text = ifelse(is.na(lag(cm)), 0, lag(cm)) + p/2 49 | ) |> 50 | ungroup() |> 51 | mutate( 52 | middle = ifelse(label == "Neutral", p, 0), 53 | pct = paste0(round(p, 2)*100, "%") 54 | ) |> 55 | filter(country != "Eswatini") |> 56 | mutate( 57 | cty = str_replace(tolower(country), "[:space:]", "-"), 58 | flag = glue("C:/Users/Dan/Documents/Assets/flag-png-round-medium/{cty}_flag-png-round-medium.png") 59 | ) 60 | 61 | df_total <- dat$afrisenti |> 62 | left_join(dat$language_countries) |> 63 | filter(country != "Eswatini") |> 64 | count(country) |> 65 | mutate(n = paste0(country, "\n", round(n/1000, 0), "k")) 66 | 67 | # 🔡 text -------------------------------------------------------------------- 68 | 69 | mastodon <- glue("") 70 | twitter <- glue("") 71 | github <- glue("") 72 | floppy <- glue("") 73 | space <- glue("'") 74 | space2 <- glue("--") # can't believe I'm doing this 75 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}AfriSenti via @shmuhammad2004") 76 | 77 | subtitle <- "Sentiment analysis of tweets from 12 African countries. Most tweets recorded from Nigeria at 64k" 78 | 79 | # 📊 plot -------------------------------------------------------------------- 80 | 81 | df_base |> 82 | ggplot() + 83 | geom_col(aes(3, p, fill = label, colour = label), width = 1, alpha = 0.9) + 84 | geom_from_path(aes(0, 0, path = flag), distinct(df_base, country, flag), width = 0.3) + 85 | geom_text(aes(4.4, y_text, label = pct), family = ft, size = 12, colour = txt) + 86 | geom_text(aes(5, 1, label = n), df_total, family = ft, size = 12, colour = txt, lineheight = 0.3) + 87 | facet_wrap(~country) + 88 | scale_fill_manual(values = pal) + 89 | scale_colour_manual(values = pal) + 90 | xlim(0, 5) + 91 | coord_polar("y", clip = "off") + 92 | labs( 93 | title = "AfriSenti: Sentiment Analysis", 94 | subtitle = subtitle, 95 | caption = caption, 96 | fill = "Sentiment", 97 | colour = "Sentiment" 98 | ) + 99 | theme_void() + 100 | theme( 101 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 102 | plot.background = element_rect(fill = bg, colour = bg), 103 | plot.title = element_text(size = 84, face = "bold", margin = margin(b = 10), hjust = 0.5), 104 | plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 10)), 105 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 106 | plot.margin = margin(b = 0, t = 0, r = 30, l = 30), 107 | # strip.text = element_text(margin = margin(t = 5, b = 5)), 108 | strip.text= element_blank(), 109 | legend.position = "bottom" 110 | ) 111 | 112 | ggsave("scripts/2023/week 9 afrisenti/afrisenti.png", height = 12, width = 12) 113 | 114 | -------------------------------------------------------------------------------- /scripts/2023/week-09-afrisenti/afrisenti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-09-afrisenti/afrisenti.png -------------------------------------------------------------------------------- /scripts/2023/week-10-numbats/numbats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-10-numbats/numbats.png -------------------------------------------------------------------------------- /scripts/2023/week-11-drugs/drugs.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggsvg) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 11) 14 | drugs <- dat$drugs 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "black" 19 | bg <- "grey90" 20 | accent <- txt 21 | 22 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 24 | font_add_google("Roboto Slab", "sono") 25 | showtext_auto() 26 | 27 | ft <- "sono" 28 | 29 | # 🤼 wrangle ----------------------------------------------------------------- 30 | 31 | n_active_sub <- drugs |> 32 | count(common_name) |> 33 | arrange(desc(n)) |> 34 | slice_head(n = 100) 35 | 36 | n_area <- drugs |> 37 | count(therapeutic_area) |> 38 | arrange(desc(n)) |> 39 | drop_na() |> 40 | slice_head(n = 100) 41 | 42 | full_grid <- expand_grid( 43 | common_name = n_active_sub$common_name, 44 | therapeutic_area = n_area$therapeutic_area 45 | ) 46 | 47 | df_count <-drugs |> 48 | semi_join(n_active_sub, by = "common_name") |> 49 | semi_join(n_area, by = "therapeutic_area") |> 50 | count(common_name, therapeutic_area) 51 | 52 | df_base <- full_grid |> 53 | left_join(df_count, by = c("common_name", "therapeutic_area")) |> 54 | mutate(n = replace_na(n, 0)) |> 55 | arrange(desc(n), common_name, therapeutic_area) |> 56 | mutate( 57 | x = as.numeric(factor(common_name)), 58 | y = as.numeric(factor(therapeutic_area)) 59 | ) |> 60 | filter(n > 0) 61 | 62 | # for the final plot 63 | df_depression <- drugs |> 64 | filter(str_detect(tolower(therapeutic_area), "depress|anxiet")) |> 65 | count(active_substance) |> 66 | mutate( 67 | active_substance = str_to_title(active_substance), 68 | active_substance = factor(active_substance), 69 | active_substance = fct_reorder(active_substance, n, max) 70 | ) |> 71 | arrange(active_substance) 72 | 73 | df_depression <- map_dfr(df_depression$active_substance, ~{ 74 | tibble( 75 | active_substance = .x, 76 | x = 1:df_depression$n[df_depression$active_substance == .x] 77 | ) 78 | }) 79 | 80 | # 🔡 text -------------------------------------------------------------------- 81 | 82 | mastodon <- glue("") 83 | twitter <- glue("") 84 | github <- glue("") 85 | floppy <- glue("") 86 | space <- glue("'") 87 | space2 <- glue("--") # can't believe I'm doing this 88 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}European Medicines Agency") 89 | 90 | cap_url <- "https://www.svgrepo.com/download/409421/capsule.svg" 91 | svg_txt <- paste(readLines(cap_url), collapse = "\n") 92 | 93 | subtitle <- "This dataset includes 20 medications for treating anxiety and depression.
94 | Pregabalin is the most common active substance." 95 | 96 | # 📊 plot -------------------------------------------------------------------- 97 | 98 | df_depression |> 99 | ggplot() + 100 | geom_point_svg(aes(x, active_substance), svg = svg_txt, size = 18) + 101 | geom_text(aes(0.5, as.numeric(active_substance)-0.4, label = active_substance), family = ft, size = 16, colour = txt, lineheight = 0.3, hjust = 0) + 102 | xlim(0.5, 10) + 103 | coord_cartesian(clip = "off") + 104 | labs( 105 | title = "Anxiety and Depression", 106 | subtitle = subtitle, 107 | caption = caption 108 | ) + 109 | theme_void() + 110 | theme( 111 | text = element_text(family = ft, size = 48, lineheight = 0.35, colour = txt), 112 | plot.title = element_text(size = 128, face = "bold", hjust = 0.15), 113 | plot.subtitle = element_markdown(hjust = 0.2, halign = 0), 114 | plot.background = element_rect(fill = bg, colour = bg), 115 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 116 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50) 117 | # axis.text.y = element_text(hjust = 1) 118 | ) 119 | 120 | ggsave("scripts/2023/week 11 drugs/drugs.png", height = 10, width = 10) 121 | -------------------------------------------------------------------------------- /scripts/2023/week-11-drugs/drugs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-11-drugs/drugs.png -------------------------------------------------------------------------------- /scripts/2023/week-12-languages/languages.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(brms) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 12) 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | txt <- "grey90" 18 | bg <- "#000080" 19 | accent <- "grey90" 20 | 21 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 22 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 23 | font_add_google("Mukta", "mukta") 24 | showtext_auto() 25 | 26 | ft <- "mukta" 27 | 28 | # 🤼 wrangle ----------------------------------------------------------------- 29 | 30 | df_base <- dat$languages |> 31 | filter( 32 | github_repo_stars > 0, 33 | github_repo_subscribers > 0 34 | ) |> 35 | mutate( 36 | stars = log(github_repo_stars), 37 | subs = log(github_repo_subscribers) 38 | ) 39 | 40 | mod <- brm(subs ~ stars, data = df_base) 41 | 42 | new_data <- tibble(stars = seq(0.1, 12, 0.1)) 43 | 44 | pred <- posterior_predict(mod, newdata = new_data) 45 | 46 | df_pred <- t(pred) |> 47 | as_tibble() |> 48 | bind_cols(new_data) |> 49 | pivot_longer(-stars, names_to = "id", values_to = "draw") |> 50 | group_by(stars) |> 51 | summarise( 52 | q5 = quantile(draw, 0.05), 53 | q10 = quantile(draw, 0.1), 54 | q25 = quantile(draw, 0.25), 55 | q50 = quantile(draw, 0.5), 56 | q75 = quantile(draw, 0.75), 57 | q90 = quantile(draw, 0.9), 58 | q95 = quantile(draw, 0.95) 59 | ) 60 | 61 | # 🔡 text -------------------------------------------------------------------- 62 | 63 | mastodon <- glue("") 64 | twitter <- glue("") 65 | github <- glue("") 66 | floppy <- glue("") 67 | space <- glue("'") 68 | space2 <- glue("--") # can't believe I'm doing this 69 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}Programming languages") 70 | 71 | # 📊 plot -------------------------------------------------------------------- 72 | 73 | df_base |> 74 | ggplot() + 75 | geom_ribbon(aes(x = stars, ymin = q5, ymax = q95), df_pred, alpha = 0.15, fill = accent) + 76 | geom_ribbon(aes(x = stars, ymin = q10, ymax = q90), df_pred, alpha = 0.15, fill = accent) + 77 | geom_ribbon(aes(x = stars, ymin = q25, ymax = q75), df_pred, alpha = 0.15, fill = accent) + 78 | geom_line(aes(x = stars, y = q50), df_pred, colour = "white") + 79 | geom_point(aes(stars, subs, size = github_repo_issues), alpha = 0.5, colour = "white") + 80 | labs( 81 | title = "PROGRAMMING LANGUAGES", 82 | subtitle = "Relationsip between Github stars and subscriptions. Each point is a programming language. 83 | Size of the point represents the number of Github issues.", 84 | caption = caption, 85 | size = "Github\nissues :(", 86 | x = "Github Stars (log scale)", 87 | y = "Github Subscription (log scale)" 88 | ) + 89 | theme_void() + 90 | theme( 91 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 92 | plot.title = element_text(size = 100), 93 | plot.background = element_rect(fill = bg, colour = bg), 94 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 95 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 96 | axis.text = element_text(), 97 | axis.title = element_text(margin = margin(t = 5)), 98 | axis.title.y = element_text(angle = 90) 99 | ) 100 | 101 | ggsave("scripts/2023/week 12 languages/languages.png", height = 12, width = 12) 102 | -------------------------------------------------------------------------------- /scripts/2023/week-12-languages/languages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-12-languages/languages.png -------------------------------------------------------------------------------- /scripts/2023/week-13-time-zones/time-zones-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-13-time-zones/time-zones-s.png -------------------------------------------------------------------------------- /scripts/2023/week-13-time-zones/time-zones.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-13-time-zones/time-zones.png -------------------------------------------------------------------------------- /scripts/2023/week-13-time-zones/times-zones.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggforce) 10 | library(ggfx) 11 | 12 | # 💾 load data --------------------------------------------------------------- 13 | 14 | dat <- tidytuesdayR::tt_load(2023, week = 13) 15 | 16 | trans <- dat$transitions 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | txt <- "white" 21 | bg <- "grey20" 22 | accent <- '#ecbf3d' 23 | 24 | pal <- c('#ecbf3d', '#f0cc46', '#f5e355', '#fdf56d', '#fdffbe', '#ffffff') 25 | 26 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 27 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 28 | font_add_google("Mukta", "mukta") 29 | font_add_google("Rubik Mono One", "rubik") 30 | showtext_auto() 31 | 32 | ft <- "mukta" 33 | ft1 <- "rubik" 34 | 35 | # 🤼 wrangle ----------------------------------------------------------------- 36 | 37 | cities <- c("Paris", "Berlin", "London", "Sydney", "New York") 38 | 39 | df_time <- trans |> 40 | group_by(zone) |> 41 | slice_max(end) |> 42 | mutate(city = str_replace(str_extract(zone, "(?<=/)[^/]*$"), "_", " ")) |> 43 | filter(city %in% cities) |> 44 | mutate( 45 | city = factor(city, levels = rev(cities)), 46 | lab = paste0(city, "."), 47 | offset = offset/3600, 48 | offset_lab = ifelse(offset < 0, as.character(offset), paste0("+", offset)) 49 | ) |> 50 | ungroup() 51 | 52 | df_circle <- map_dfr(cities, ~{ 53 | tibble( 54 | x = 0, 55 | y = 0, 56 | r = seq(1, 0.75, length = 10), 57 | col = colorRampPalette(pal)(10), 58 | city = .x 59 | ) 60 | }) |> 61 | mutate(city = factor(city, levels = rev(cities))) |> 62 | left_join( 63 | df_time |> 64 | select(city, offset), 65 | by = "city" 66 | ) |> 67 | mutate(y = as.numeric(city)) 68 | 69 | # 🔡 text -------------------------------------------------------------------- 70 | 71 | mastodon <- glue("") 72 | twitter <- glue("") 73 | github <- glue("") 74 | floppy <- glue("") 75 | space <- glue("'") 76 | space2 <- glue("--") # can't believe I'm doing this 77 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}IANA tz database") 78 | 79 | # 📊 plot -------------------------------------------------------------------- 80 | 81 | df_time |> 82 | ggplot() + 83 | geom_text(aes(0, city, label = lab), family = ft1, size = 48, colour = ifelse(df_time$dst, accent, txt), hjust = 0, fontface = "bold") + 84 | geom_text(aes(3.8, city, label = offset_lab), family = ft, colour = txt, size = 24, fontface = "bold") + 85 | geom_segment(aes(x=4, xend = 8, y = city, yend = city), colour = txt) + 86 | with_inner_glow( 87 | geom_circle(aes(x0 = offset/6+6, y0 = y, r = r/2, fill = col, group = city), df_circle, colour = NA), 88 | colour = bg, expand = 2, sigma = 5 89 | ) + 90 | scale_fill_identity() + 91 | coord_fixed() + 92 | labs( 93 | title = "TIME ZONES", 94 | subtitle = glue("Time zone offsets and daylight savings"), 95 | caption = caption 96 | ) + 97 | theme_void() + 98 | theme( 99 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 100 | plot.background = element_rect(fill = bg, colour = bg), 101 | plot.title = element_markdown(colour = txt, hjust = 0.05, margin = margin(t = 20), size = 128, face = "bold", family = ft1), 102 | plot.subtitle = element_markdown(colour = txt, hjust = 0.05, margin = margin(t = 20)), 103 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 104 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50) 105 | ) 106 | 107 | ggsave("scripts/2023/week 13 timezones/timezones.png", height = 12, width = 16) 108 | -------------------------------------------------------------------------------- /scripts/2023/week-14-soccer/logos.csv: -------------------------------------------------------------------------------- 1 | team,hex_code,logo 2 | Arsenal,#EF0107,https://a.espncdn.com/i/teamlogos/soccer/500/359.png 3 | Aston Villa,#95BFE5,https://a.espncdn.com/i/teamlogos/soccer/500/362.png 4 | Brentford,#FFC600,https://a.espncdn.com/i/teamlogos/soccer/500/337.png 5 | Brighton,#0057B8,https://a.espncdn.com/i/teamlogos/soccer/500/331.png 6 | Burnley,#6C1D45,https://a.espncdn.com/i/teamlogos/soccer/500/379.png 7 | Chelsea,#034694,https://a.espncdn.com/i/teamlogos/soccer/500/363.png 8 | Crystal Palace,#1B458F,https://a.espncdn.com/i/teamlogos/soccer/500/384.png 9 | Everton,#003399,https://a.espncdn.com/i/teamlogos/soccer/500/368.png 10 | Leeds,#FFCD00,https://a.espncdn.com/i/teamlogos/soccer/500/357.png 11 | Leicester,#0053A0,https://a.espncdn.com/i/teamlogos/soccer/500/375.png 12 | Liverpool,#C8102E,https://a.espncdn.com/i/teamlogos/soccer/500/364.png 13 | Man City,#6CABDD,https://a.espncdn.com/i/teamlogos/soccer/500/382.png 14 | Man United,#E03A3E,https://a.espncdn.com/i/teamlogos/soccer/500/360.png 15 | Newcastle,#241F20,https://a.espncdn.com/i/teamlogos/soccer/500/361.png 16 | Norwich,#00A650,https://a.espncdn.com/i/teamlogos/soccer/500/381.png 17 | Southampton,#D71920,https://a.espncdn.com/i/teamlogos/soccer/500/376.png 18 | Tottenham,#FFFFFF,https://a.espncdn.com/i/teamlogos/soccer/500/367.png 19 | Watford,#FBEE23,https://a.espncdn.com/i/teamlogos/soccer/500/395.png 20 | West Ham,#7A263A,https://a.espncdn.com/i/teamlogos/soccer/500/371.png 21 | Wolves,#FDB913,https://a.espncdn.com/i/teamlogos/soccer/500/380.png 22 | -------------------------------------------------------------------------------- /scripts/2023/week-14-soccer/soccer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-14-soccer/soccer.png -------------------------------------------------------------------------------- /scripts/2023/week-15-eggs/eggs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-15-eggs/eggs.png -------------------------------------------------------------------------------- /scripts/2023/week-16-crops/crops.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-16-crops/crops.png -------------------------------------------------------------------------------- /scripts/2023/week-17-london-marathon/london-marathon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-17-london-marathon/london-marathon.png -------------------------------------------------------------------------------- /scripts/2023/week-18-portal/portal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-18-portal/portal.png -------------------------------------------------------------------------------- /scripts/2023/week-19-childcare/childcare.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(mapdata) 10 | library(biscale) 11 | 12 | # 💾 load data --------------------------------------------------------------- 13 | 14 | dat <- tidytuesdayR::tt_load(2023, week = 19) 15 | 16 | costs <- dat$childcare_costs 17 | counties <- dat$counties 18 | 19 | # ✍️ fonts and palettes ------------------------------------------------------ 20 | 21 | txt <- "grey20" 22 | bg <- "white" 23 | accent <- txt 24 | bi <- "BlueGold" 25 | 26 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 27 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 28 | font_add_google("Fira Sans", "fira") 29 | showtext_auto() 30 | ft <- "fira" 31 | 32 | # 🤼 wrangle ----------------------------------------------------------------- 33 | 34 | df <- costs |> 35 | filter(study_year == 2018) |> 36 | group_by(county_fips_code) |> 37 | summarise( 38 | poverty = mean(pr_f, na.rm = TRUE), 39 | cost = mean(mfcc_infant, na.rm = TRUE) 40 | ) |> 41 | drop_na() |> 42 | bi_class(x = poverty, y = cost, style = "quantile", dim = 3) |> 43 | left_join(counties, by = "county_fips_code") |> 44 | mutate(county = str_remove(county_name, " County")) 45 | 46 | df_county <- map_data("county") |> 47 | as_tibble() |> 48 | mutate(county = str_to_title(subregion)) |> 49 | left_join(df, by = "county") 50 | 51 | legend <- bi_legend( 52 | pal = bi, 53 | dim = 3, 54 | xlab = "Higher rate of poverty ", 55 | ylab = "Higher cost of services ", 56 | size = 32) 57 | 58 | # 🔡 text -------------------------------------------------------------------- 59 | 60 | mastodon <- glue("") 61 | twitter <- glue("") 62 | github <- glue("") 63 | floppy <- glue("") 64 | space <- glue("'") 65 | space2 <- glue("--") # can't believe I'm doing this 66 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}National Database of Childcare Prices") 67 | 68 | subtitle <- str_wrap("Since 1998, the federal Administration for Children and Families (ACF) at the U.S. 69 | Department of Health and Human Services has required states to conduct a study of 70 | childcare market prices to evaluate adequacy of state reimbursement rates for the purpose of 71 | demonstrating equal access to childcare for low-income families. States use the results of 72 | market price surveys to inform rate-setting policy and to establish maximum reimbursement 73 | rates for children served through childcare assistance programs. While market price surveys 74 | may include multiple segments of the childcare market, at their core they are designed to 75 | collect and report prices on providers that are operating in the regulated market for childcare.", 200) 76 | 77 | 78 | # 📊 plot -------------------------------------------------------------------- 79 | 80 | g_base <- ggplot() + 81 | geom_polygon(aes(long, lat, group = group, fill = bi_class), df_county, colour = "black", size = 0.1) + 82 | bi_scale_fill(pal = bi, dim = 3) + 83 | coord_map() + 84 | labs( 85 | title = "Cost of Childcare Services and Poverty Rate across the US", 86 | subtitle = subtitle, 87 | caption = caption 88 | ) + 89 | theme_void() + 90 | theme( 91 | legend.position = "none", 92 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 93 | plot.title = element_text(size = 84, hjust = 0, face = "bold"), 94 | plot.subtitle = element_text(size = 36), 95 | plot.background = element_rect(fill = bg, colour = bg), 96 | plot.caption = element_markdown(hjust = 0.5, margin = margin(t = 20)), 97 | plot.margin = margin(b = 0, t = 0, r = 50, l = 50) 98 | ) 99 | 100 | g_base + 101 | inset_element(legend, left = -0.05, right = 0.25, bottom = -0.05, top = 0.25) 102 | 103 | ggsave("scripts/2023/week-19-childcare/childcare.png", height = 12, width = 18) 104 | -------------------------------------------------------------------------------- /scripts/2023/week-19-childcare/childcare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-19-childcare/childcare.png -------------------------------------------------------------------------------- /scripts/2023/week-20-tornados/tornados.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-20-tornados/tornados.png -------------------------------------------------------------------------------- /scripts/2023/week-21-squirrels/squirrels.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggpath) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 21) 14 | 15 | df <- dat$squirrel_data |> 16 | clean_names() 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | txt <- "black" 21 | bg <- "white" 22 | accent <- "black" 23 | 24 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 25 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 26 | font_add_google("Barlow", "bar") 27 | showtext_auto() 28 | 29 | ft <- "bar" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df_actions <- df |> 34 | summarise( 35 | running = sum(running), 36 | chasing = sum(chasing), 37 | climbing = sum(climbing), 38 | eating = sum(eating), 39 | foraging = sum(foraging) 40 | ) |> 41 | pivot_longer(everything(), names_to = "action", values_to = "n") |> 42 | mutate( 43 | p = n/sum(n), 44 | pct = glue("{round(p*100)}%"), 45 | action = str_to_title(action) 46 | ) 47 | 48 | df_coords <- tribble( 49 | ~action, ~x0, ~y0, ~r, ~x1, ~y1, ~grp, 50 | "Running", 0.1, 0.4, 0.05, 0.1, 0.16, 1, 51 | "Chasing", 0.3, 0.5, 0.05, 0.3, 0.25, 0, 52 | "Chasing", 0.3, 0.25, 0.05, 0.35, 0.15, 2, 53 | "Eating", 0.8, 0.4, 0.05, 0.8, 0.17, 1, 54 | "Foraging", 0.95, 0.4, 0.05, 0.95, 0.13, 1, 55 | "Climbing", 0.48, 0.6, 0.05, 0.48, 0.39, 1 56 | ) |> 57 | left_join(df_actions, by = "action") 58 | 59 | # 🔡 text -------------------------------------------------------------------- 60 | 61 | mastodon <- glue("") 62 | twitter <- glue("") 63 | github <- glue("") 64 | floppy <- glue("") 65 | space <- glue("'") 66 | space2 <- glue("--") # can't believe I'm doing this 67 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}2018 Central Park Squirrel Census") 68 | 69 | # 📊 plot -------------------------------------------------------------------- 70 | 71 | a <- 0.02 72 | b <- 0.01 73 | df_coords |> 74 | ggplot() + 75 | geom_from_path(aes(0.5, 0.5, path = "scripts/2023/week-21-squirrels/base.png")) + 76 | geom_segment(aes(x = x0, xend = x1, y = y0, yend = y1), colour = "black") + 77 | geom_point(aes(x1, y1), filter(df_coords, grp >= 1), size = 3) + 78 | geom_circle(aes(x0 = x0, y0 = y0, r = r), filter(df_coords, grp <= 1), fill = bg, colour = "black", size = 0.5) + 79 | geom_text(aes(x = x0, y = y0-a, label = action), filter(df_coords, grp <= 1), family = ft, size = 14, colour = txt, fontface = "bold") + 80 | geom_text(aes(x = x0, y = y0+b, label = pct), filter(df_coords, grp <= 1), family = ft, size = 28, colour = txt, fontface = "bold") + 81 | annotate("text", x = 1, y = 1, hjust = 1, vjust = 1, family = ft, size = 36, fontface = "bold", colour = "white", 82 | label = "A day in the life of a\nsquirrel in Central Park", lineheight = 0.3) + 83 | xlim(0, 1) + 84 | ylim(0, 1) + 85 | coord_fixed(clip = "off") + 86 | labs( 87 | caption = caption 88 | ) + 89 | theme_void() + 90 | theme( 91 | plot.margin = margin(t = 10, b = 40, l = 10, r = 10), 92 | plot.background = element_rect(fill = bg, colour = "white"), 93 | plot.caption = element_markdown(margin = margin(b = 20, t = 10), size = 36, family = ft, colour = txt, hjust = 0.5) 94 | ) 95 | 96 | ggsave("scripts/2023/week-21-squirrels/squirrels.png", height = 12, width = 12) 97 | -------------------------------------------------------------------------------- /scripts/2023/week-21-squirrels/squirrels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-21-squirrels/squirrels.png -------------------------------------------------------------------------------- /scripts/2023/week-22-centenarians/centenarians.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-22-centenarians/centenarians.png -------------------------------------------------------------------------------- /scripts/2023/week-23-energy/energy-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-23-energy/energy-s.png -------------------------------------------------------------------------------- /scripts/2023/week-23-energy/energy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-23-energy/energy.png -------------------------------------------------------------------------------- /scripts/2023/week-24-safi/safi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-24-safi/safi.png -------------------------------------------------------------------------------- /scripts/2023/week-25-ufo/ufo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-25-ufo/ufo.png -------------------------------------------------------------------------------- /scripts/2023/week-26-us-places/us-places.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(mapdata) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 26) 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | txt <- "grey20" 18 | bg <- "#D4D4D4" 19 | bg <- "#f7e4c6" 20 | accent <- "#875346" 21 | 22 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 24 | font_add_google("Noticia Text", "bar") 25 | font_add_google("Monoton", "mon") 26 | showtext_auto() 27 | 28 | ft <- "bar" 29 | ft1 <- "mon" 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df_cali <- dat$us_place_names |> 34 | filter(state_name == "California") |> 35 | filter(str_detect(tolower(feature_name), "mountain")) |> 36 | select(x = prim_long_dec, y = prim_lat_dec, everything()) |> 37 | drop_na() |> 38 | left_join(distinct(dat$us_place_history, feature_id, description, history), by = "feature_id") |> 39 | arrange(desc(y)) |> 40 | mutate( 41 | id = 1:n(), 42 | label = glue("{feature_name}"), 43 | point = glue("{id} "), 44 | y_text = seq(42, min(y), length = n()), 45 | text = coalesce(history, description) 46 | ) 47 | 48 | cali <- map_data("state") |> 49 | filter(region == "california") 50 | 51 | # 🔡 text -------------------------------------------------------------------- 52 | 53 | mastodon <- glue("") 54 | twitter <- glue("") 55 | github <- glue("") 56 | floppy <- glue("") 57 | space <- glue("'") 58 | space2 <- glue("--") # can't believe I'm doing this 59 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}Historical Marker Database") 60 | 61 | subtitle <- "Mountain related\nstuff in California" 62 | 63 | # 📊 plot -------------------------------------------------------------------- 64 | 65 | df_cali |> 66 | ggplot(aes(x, y)) + 67 | geom_polygon(aes(long, lat), cali, fill = "#cddbc2", colour = txt) + 68 | geom_text(aes(-128, y_text, label = label), family = ft, colour = txt, size = 12, hjust = 0) + 69 | geom_text(aes(-128.2, y_text, label = id), family = ft, colour = txt, size = 12, vjust = 1, fontface = "bold") + 70 | geom_richtext(aes(x, powerglove::breathing_space(y, diff = 0.1), label = point), family = ft, colour = txt, size = 12, label.color = NA, fill = NA) + 71 | geom_text(aes(-128, y_text-0.1, label = str_wrap(text, 70)), family = ft, colour = txt, size = 6, hjust = 0, lineheight = 0.25, vjust = 1) + 72 | annotate("text", x = -118, y = 41, label = subtitle, family = ft, size = 24, colour = txt, hjust = 0, vjust = 1, lineheight = 0.35) + 73 | coord_map() + 74 | labs( 75 | title = "CALIFORNIA", 76 | caption = caption 77 | ) + 78 | theme_void() + 79 | theme( 80 | text = element_text(family = ft, colour = txt, size = 48), 81 | plot.background = element_rect(fill = bg, colour = bg), 82 | plot.title = element_text(size = 260, family = ft1, hjust = 0.5, colour = "#875346"), 83 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 84 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50) 85 | ) 86 | 87 | ggsave("scripts/2023/week-26-us-places/us-places.png", height = 12, width = 12) 88 | -------------------------------------------------------------------------------- /scripts/2023/week-26-us-places/us-places.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-26-us-places/us-places.png -------------------------------------------------------------------------------- /scripts/2023/week-27-markers/markers.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 27) 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | txt <- "grey20" 17 | bg <- "white" 18 | accent <- "grey20" 19 | 20 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 21 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 22 | font_add_google("Mukta", "mukta") 23 | font_add_google("Graduate", "grad") 24 | showtext_auto() 25 | 26 | ft <- "mukta" 27 | ft1 <- "grad" 28 | 29 | # 🤼 wrangle ----------------------------------------------------------------- 30 | 31 | df_base <- dat$historical_markers |> 32 | count(state = state_or_prov) |> 33 | arrange(desc(n)) |> 34 | mutate(state = fct_reorder(state, n, max)) |> 35 | slice_head(n = 20) |> 36 | mutate( 37 | fill = letters[1:20], 38 | n_lab = paste0(round(n/1000, 1), "k"), 39 | state_lab = ifelse(as.character(state) == "District of Columbia", "D.C.", as.character(state)), 40 | state_lab = str_wrap(state_lab, 10) 41 | ) 42 | 43 | make_fat_arrow <- function(xmin, xmax, ymin, ymax, edge_length = 0.2, body_length = 0.66) { 44 | 45 | dx <- xmax-xmin 46 | dy <- ymax-ymin 47 | 48 | tibble( 49 | x = c(xmin, xmin, xmin+dx*body_length, xmin+dx*body_length, xmax, xmin+dx*body_length, xmin+dx*body_length, xmin), 50 | y = c(ymin+dy*edge_length, ymax-dy*edge_length, ymax-dy*edge_length, ymax, ymin+0.5*dy, ymin, ymin+dy*edge_length, ymin+dy*edge_length) 51 | ) 52 | 53 | } 54 | 55 | df_fat_arrow <- make_fat_arrow(12, 19, 4500, 11000) 56 | 57 | # 🔡 text -------------------------------------------------------------------- 58 | 59 | mastodon <- glue("") 60 | twitter <- glue("") 61 | github <- glue("") 62 | floppy <- glue("") 63 | space <- glue("'") 64 | space2 <- glue("--") # can't believe I'm doing this 65 | caption <- glue("{mastodon}{space2}@danoehm@{space}fosstodon.org{space2}{twitter}{space2}@danoehm{space2}{github}{space2}doehm/tidytues{space2}{floppy}{space2}Historical Maraker Database") 66 | 67 | title <- "EVERYTHING'S\nBIGGER IN" 68 | subtitle <- 69 | "The top 20 states with the most 70 | markers. Texas has 3 times as many 71 | as second place Georgia" 72 | 73 | # 📊 plot -------------------------------------------------------------------- 74 | 75 | df_base |> 76 | ggplot() + 77 | geom_brick(aes(state, n, fill = n), colour = NA, size = 0.2) + 78 | geom_text(aes(state, y = n+700, label = state_lab), family = ft, colour = txt, lineheight = 0.25, size = 16, fontface = "bold", vjust = 0) + 79 | geom_text(aes(state, y = n+350, label = n_lab), family = ft, colour = txt, lineheight = 0.25, size = 16) + 80 | geom_polygon(aes(x, y), df_fat_arrow, fill = "grey90", colour = txt) + 81 | annotate("shadowtext", x = 2, y = 11000, label = title, size = 84, family = ft1, lineheight = 0.26, colour = "white", hjust = 0, vjust = 1, fontface = "bold") + 82 | annotate("shadowtext", x = 2, y = 7800, label = "TEXAS", size = 200, family = ft1, lineheight = 0.3, colour = "white", hjust = 0, vjust = 1, fontface = "bold") + 83 | annotate("text", x = 13, y = 8500, label = "...even the arrow annotations!", family = ft, colour = txt, lineheight = 0.25, size = 16, hjust = 0, vjust = 1) + 84 | annotate("text", x = 13, y = 7500, label = subtitle, family = ft, colour = txt, lineheight = 0.25, size = 16, hjust = 0, vjust = 1) + 85 | scale_fill_gradientn(colours = c("darkblue", mid = "white", high = "firebrick4")) + 86 | labs( 87 | caption = caption, 88 | fill = "Number of\nHistorical\nMarkers" 89 | ) + 90 | theme_void() + 91 | theme( 92 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 93 | plot.background = element_rect(fill = bg, colour = bg), 94 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 95 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 96 | legend.title = element_text(size = 40) 97 | ) 98 | 99 | ggsave("scripts/2023/week-27-markers/markers.png", height = 10, width = 20) 100 | -------------------------------------------------------------------------------- /scripts/2023/week-27-markers/markers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-27-markers/markers.png -------------------------------------------------------------------------------- /scripts/2023/week-28-temperatures/hist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-28-temperatures/hist.png -------------------------------------------------------------------------------- /scripts/2023/week-28-temperatures/nh-temperatures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-28-temperatures/nh-temperatures.png -------------------------------------------------------------------------------- /scripts/2023/week-28-temperatures/sh-temperatures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-28-temperatures/sh-temperatures.png -------------------------------------------------------------------------------- /scripts/2023/week-28-temperatures/temperatures.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-28-temperatures/temperatures.png -------------------------------------------------------------------------------- /scripts/2023/week-29-gpt/gpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-29-gpt/gpt.png -------------------------------------------------------------------------------- /scripts/2023/week-30-scurvy/scurvy-2-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-30-scurvy/scurvy-2-s.png -------------------------------------------------------------------------------- /scripts/2023/week-30-scurvy/scurvy-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-30-scurvy/scurvy-2.png -------------------------------------------------------------------------------- /scripts/2023/week-31-us-states/us-states-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-31-us-states/us-states-s.png -------------------------------------------------------------------------------- /scripts/2023/week-31-us-states/us-states.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-31-us-states/us-states.png -------------------------------------------------------------------------------- /scripts/2023/week-32-hot-ones/hot-ones-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-32-hot-ones/hot-ones-s.png -------------------------------------------------------------------------------- /scripts/2023/week-32-hot-ones/hot-ones.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 32) 13 | 14 | attach(dat) 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "grey20" 19 | bg <- "#cad2c5" 20 | accent <- '#230827' 21 | 22 | hot_sauce <- c('#ff813c', '#fe5454', '#7b265d', '#4a1647', '#230827') 23 | 24 | font_add("fa-brands", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-brands-400.ttf") 25 | font_add("fa-solid", regular = "assets/fonts/fontawesome-free-6.2.0-web/fa-solid-900.ttf") 26 | font_add_google("Advent Pro", "advent") 27 | font_add_google("Passion One", "passion") 28 | font_add_google("Bangers", "bang") 29 | ft <- "advent" 30 | ft1 <- "bang" 31 | showtext_auto() 32 | 33 | # 🤼 wrangle ----------------------------------------------------------------- 34 | 35 | df_base <- sauces |> 36 | mutate(l_scov = log(scoville)) 37 | 38 | # 🔡 text -------------------------------------------------------------------- 39 | 40 | caption <- make_caption(accent, "Hot Ones") 41 | 42 | chilli <- "" 43 | 44 | # 📊 plot -------------------------------------------------------------------- 45 | 46 | df_base |> 47 | ggplot() + 48 | geom_richtext(aes(sauce_number, -season, label = chilli, colour = l_scov), label.colour = NA, size = 32, fill = NA) + 49 | geom_text(aes(0, -season, label = season), family = ft, colour = txt, size = 16) + 50 | geom_text(aes(sauce_number, 0, label = sauce_number), family = ft, colour = txt, size = 16) + 51 | annotate("text", x = 0, y = 0, label = "Season", family = ft, colour = txt, size = 16, hjust = 1) + 52 | annotate("text", x = 1, y = 1, label = "Sauce number", family = ft, colour = txt, size = 16, hjust = 0) + 53 | scale_colour_gradientn( 54 | colours = hot_sauce, 55 | breaks = log(c(2000, 20000, 200000, 2000000)), 56 | labels = c("2k", "20k", "200k", "2M") 57 | ) + 58 | labs( 59 | title = "HOT ONES!", 60 | caption = caption, 61 | colour = "Scoville units" 62 | ) + 63 | coord_cartesian(clip = "off") + 64 | theme_void() + 65 | theme( 66 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 67 | plot.background = element_rect(fill = bg, colour = bg), 68 | plot.title = element_text(family = ft1, size = 220, hjust = 0.5, face = "italic"), 69 | plot.subtitle = element_text(), 70 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20), face = "italic"), 71 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 72 | legend.position = "bottom" 73 | ) 74 | 75 | ggsave("scripts/2023/week-32-hot-ones/hot-ones.png", height = 12, width = 8) 76 | -------------------------------------------------------------------------------- /scripts/2023/week-32-hot-ones/hot-ones.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-32-hot-ones/hot-ones.png -------------------------------------------------------------------------------- /scripts/2023/week-33-spam/spam-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-33-spam/spam-s.png -------------------------------------------------------------------------------- /scripts/2023/week-33-spam/spam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-33-spam/spam.png -------------------------------------------------------------------------------- /scripts/2023/week-34-refugees/refugees-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-34-refugees/refugees-s.png -------------------------------------------------------------------------------- /scripts/2023/week-34-refugees/refugees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-34-refugees/refugees.png -------------------------------------------------------------------------------- /scripts/2023/week-35-copyright/copyright-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-35-copyright/copyright-s.png -------------------------------------------------------------------------------- /scripts/2023/week-35-copyright/copyright.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 35) 13 | cases <- dat$fair_use_cases 14 | findings <- dat$fair_use_findings 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "grey20" 19 | bg <- "white" 20 | accent <- "grey20" 21 | 22 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 24 | font_add_google("Barlow", "bar") 25 | ft <- "bar" 26 | showtext_auto() 27 | 28 | # 🤼 wrangle ----------------------------------------------------------------- 29 | 30 | # For fuck sake 31 | # Rstudio replaced my code with an old version 32 | # I'm not re-writing it 33 | 34 | # 🔡 text -------------------------------------------------------------------- 35 | 36 | caption <- make_caption(accent, "Data") 37 | 38 | # 📊 plot -------------------------------------------------------------------- 39 | 40 | ggplot() + 41 | geom_rect(aes(xmin = 0, xmax = 1, ymin = y, ymax = y+0.5), df_base_1, fill = NA, colour = "black") + 42 | geom_segment(aes(x = z, xend = z, y = y, yend = y+0.5, group = id), df, alpha = 0.1) + 43 | labs(caption = caption) + 44 | theme_void() + 45 | theme( 46 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 47 | plot.background = element_rect(fill = bg, colour = bg), 48 | plot.title = element_text(size = 128, hjust = 0.5), 49 | plot.subtitle = element_text(), 50 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 51 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50) 52 | ) 53 | 54 | ggsave("scripts/2023/week-xx-yy/yy.png", height = 12, width = 12) 55 | -------------------------------------------------------------------------------- /scripts/2023/week-35-copyright/copyright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-35-copyright/copyright.png -------------------------------------------------------------------------------- /scripts/2023/week-36-unions/unions-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-36-unions/unions-s.png -------------------------------------------------------------------------------- /scripts/2023/week-36-unions/unions.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | demographics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/demographics.csv') 13 | wages <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/wages.csv') 14 | states <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/states.csv') 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "white" 19 | bg <- '#1E212B' 20 | accent <- "orange" 21 | pal <- c("#fb8500", "#ffb703") 22 | 23 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 25 | font_add_google("Barlow", "bar") 26 | font_add_google("Josefin Sans", "jose") 27 | font_add_google("Arimo", "arimo") 28 | ft <- "bar" 29 | ft <- "jose" 30 | ft <- "arimo" 31 | showtext_auto() 32 | 33 | # 🤼 wrangle ----------------------------------------------------------------- 34 | 35 | df_base <- demographics |> 36 | filter(facet %in% c("private sector: all", "public sector: all")) |> 37 | select(year, p_members, p_covered, facet) |> 38 | filter(year %in% c(1990, 2020)) |> 39 | mutate( 40 | pct = to_pct(p_members), 41 | x1 = ifelse(year == 1990, 1985, 2025) 42 | ) |> 43 | left_join( 44 | wages |> 45 | select(year, wage, facet), 46 | by = c("year", "facet") 47 | ) |> 48 | group_by(year) |> 49 | mutate( 50 | ratio = wage/wage[facet == "private sector: all"], 51 | r_pct = paste0("+", to_pct(ratio-1)), 52 | ratio_members = p_members/p_members[facet == "private sector: all"], 53 | r_pct_members = paste0("+", to_pct(ratio_members)) 54 | ) 55 | 56 | # 🔡 text -------------------------------------------------------------------- 57 | 58 | caption <- make_caption(accent, "Data") 59 | title <- "US Union Membership" 60 | text <- glue( 61 | "Historically the {ct('public sector', pal[2])} has had much higher rates of union membership than the {ct('private sector', pal[1])}.
62 | From 1990 to 2020 union membership in the US has dropped {ct('1%', pal[2])} point in the {ct('public sector', pal[2])} and {ct('6%', pal[1])}
63 | points in the {ct('private sector', pal[1])} in terms of the percentage of total employment, effectively halving the
64 | rate from 1990. Wages for the {ct('public sector', pal[2])} were, on average, 18% higher than the {ct('private sector', pal[1])}
65 | in 1990 and only 4% in 2020") 66 | 67 | # 📊 plot -------------------------------------------------------------------- 68 | 69 | df_base |> 70 | ggplot() + 71 | with_shadow( 72 | geom_line(aes(year, p_members, group = facet, colour = facet), linewidth = 10, lineend = "round"), 73 | x_offset = 30, 74 | y_offset = 30 75 | ) + 76 | geom_text(aes(x = x1, y = p_members, colour = facet, label = pct), family = ft, size = 48) + 77 | geom_text(aes(x = year, y = 0, label = year), family = ft, size = 24, colour = txt) + 78 | annotate("text", x = 2005, y = 0.355+0.05, label = "Public", family = ft, colour = pal[2], size = 32) + 79 | annotate("text", x = 2005, y = 0.09+0.05, label = "Private", family = ft, colour = pal[1], size = 32, angle = 356) + 80 | annotate("text", x = 2005, y = 1, label = title, family = ft, colour = txt, size = 64, fontface = "bold", vjust = 1) + 81 | annotate("richtext", x = 2005, y = 0.88, label = text, family = ft, colour = txt, size = 16, vjust = 1, lineheight = 0.35, 82 | label.color = NA, fill = NA) + 83 | scale_colour_manual(values = pal) + 84 | ylim(0, 1) + 85 | labs(caption = caption) + 86 | coord_cartesian(clip = "off") + 87 | theme_void() + 88 | theme( 89 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 90 | plot.background = element_rect(fill = bg, colour = bg), 91 | plot.title = element_text(size = 128, hjust = 0.5), 92 | plot.subtitle = element_text(), 93 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 30)), 94 | plot.margin = margin(b = 150, t = 120, r = 150, l = 150), 95 | legend.position = "none" 96 | ) 97 | 98 | ggsave("scripts/2023/week-36-unions/unions.png", height = 12, width = 12) 99 | 100 | -------------------------------------------------------------------------------- /scripts/2023/week-36-unions/unions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-36-unions/unions.png -------------------------------------------------------------------------------- /scripts/2023/week-37-global-human-day/global-human-day-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-37-global-human-day/global-human-day-s.png -------------------------------------------------------------------------------- /scripts/2023/week-37-global-human-day/global-human-day.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-37-global-human-day/global-human-day.png -------------------------------------------------------------------------------- /scripts/2023/week-38-cran/cran-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-38-cran/cran-s.png -------------------------------------------------------------------------------- /scripts/2023/week-38-cran/cran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-38-cran/cran.png -------------------------------------------------------------------------------- /scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count-s.png -------------------------------------------------------------------------------- /scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 39) 13 | 14 | rich <- dat$richmondway |> 15 | clean_names() 16 | 17 | # ✍️ fonts and palettes ------------------------------------------------------ 18 | 19 | txt <- "grey20" 20 | bg <- "white" 21 | accent <- pencil_case$pal1[2] 22 | 23 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 25 | font_add_google("Bangers", "bang") 26 | font_add_google("Barlow", "bar") 27 | ft <- "bar" 28 | ft1 <- "bang" 29 | showtext_auto() 30 | 31 | # 🤼 wrangle ----------------------------------------------------------------- 32 | 33 | df <- rich |> 34 | rename(n_fucks = f_count_total) |> 35 | mutate(angle = runif(n(), 350, 360)) 36 | 37 | df_fck <- df |> 38 | group_by(season) |> 39 | summarise(episode = max(episode) + 1) |> 40 | mutate(fck = "CK!") |> 41 | bind_rows( 42 | tibble( 43 | season = 1:3, 44 | episode = 0, 45 | fck = "F" 46 | ) 47 | ) |> 48 | mutate( 49 | n_fucks = 30 50 | ) 51 | 52 | df_total <- df |> 53 | group_by(season) |> 54 | summarise(n_fucks = sum(n_fucks)) 55 | 56 | df_season <- tibble( 57 | x = 0, 58 | y = 1:3 + 0.3, 59 | lab = paste("Season", 1:3, " - ", df_total$n_fucks) 60 | ) 61 | 62 | # 🔡 text -------------------------------------------------------------------- 63 | 64 | subtitle <- "The number of f-bombs unleashed by Roy Kent in Ted Lasso by season. Each 'U' is an episode and the number of fucks." 65 | caption <- make_caption(accent) 66 | 67 | caption <- paste0(subtitle, "
", caption) 68 | 69 | # 📊 plot -------------------------------------------------------------------- 70 | 71 | df |> 72 | ggplot() + 73 | geom_text(aes(x = episode, y = -season, label = "U"), family = ft1, colour = accent, fontface = "bold", size = df$n_fucks*3, hjust = 0.5, angle = df$angle) + 74 | geom_text(aes(x = episode, y = -season, label = fck, size = n_fucks), df_fck, family = ft1, colour = txt, fontface = "bold", size = 90, hjust = 0.25) + 75 | geom_text(aes(x = x, y = -y, label = lab), df_season, family = ft, size = 12, colour = txt, hjust = 0, fontface = "italic") + 76 | # annotate("text", x = 8, y = -3.6, label = subtitle, family = ft, size = 12, colour = txt, fontface = "italic") + 77 | coord_cartesian(clip = "off") + 78 | labs(caption = caption) + 79 | theme_void() + 80 | theme( 81 | text = element_text(family = ft, size = 42, lineheight = 0.3, colour = txt), 82 | plot.background = element_rect(fill = bg, colour = bg), 83 | plot.title = element_text(size = 128, hjust = 0.5), 84 | plot.subtitle = element_text(), 85 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 150), face = "italic", lineheight = 0.6), 86 | plot.margin = margin(b = 50, t = 200, r = 200, l = 150) 87 | ) 88 | 89 | ggsave("scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count.png", height = 12, width = 12) 90 | 91 | -------------------------------------------------------------------------------- /scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count.png -------------------------------------------------------------------------------- /scripts/2023/week-40-US-grants/US-grants-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-40-US-grants/US-grants-s.png -------------------------------------------------------------------------------- /scripts/2023/week-40-US-grants/us-grants.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(snakecase) 10 | library(colorspace) 11 | 12 | # 💾 load data --------------------------------------------------------------- 13 | 14 | dat <- tidytuesdayR::tt_load(2023, week = 40) 15 | grants <- dat$grants 16 | details <- dat$grant_opportunity_details 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | txt <- "grey20" 21 | bg <- "white" 22 | accent <- "#2f3c68" 23 | pal <- c('#4a166a', '#ce5068', '#f0d35b', '#61aa6f', "#2f3c68") 24 | pal24 <- colorRampPalette(pal)(24) 25 | 26 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 27 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 28 | font_add_google("Barlow", "bar") 29 | ft <- "bar" 30 | showtext_auto() 31 | 32 | # 🤼 wrangle ----------------------------------------------------------------- 33 | 34 | df_base <- details |> 35 | select(starts_with("category"), -category_explanation) |> 36 | summarise_all(~sum(.x)) |> 37 | pivot_longer(everything(), names_to = "category") |> 38 | mutate(category = str_remove(category, "category_")) |> 39 | mutate(pct = to_pct(value/2000, 3)) |> 40 | mutate(lab = toupper(to_title_case(category))) |> 41 | mutate(category = fct_reorder(factor(category), value, min)) |> 42 | arrange(desc(category)) 43 | 44 | df_tile <- map_dfr(1:nrow(df_base), ~{ 45 | expand_grid(x = 1:200, y = 1:10) |> 46 | mutate( 47 | category = df_base$category[.x], 48 | fill = ifelse(row_number() <= df_base$value[.x], pal24[.x], NA) 49 | ) 50 | }) 51 | 52 | # 🔡 text -------------------------------------------------------------------- 53 | 54 | caption <- make_caption(pal[1]) 55 | 56 | # 📊 plot -------------------------------------------------------------------- 57 | 58 | df_tile |> 59 | ggplot() + 60 | geom_tile(aes(x = x, y = y, fill = fill), width = 0.9, height = 0.9, colour = "grey90") + 61 | geom_text(aes(x = 199, y = 5, label = lab), df_base, hjust = 1, vjust = 0, colour = txt, size = 26, fontface = "bold", family = ft) + 62 | geom_text(aes(x = 199, y = 1, label = pct), df_base, hjust = 1, vjust = 0, colour = txt, size = 16, family = ft) + 63 | facet_wrap(~category, ncol = 1) + 64 | scale_fill_identity() + 65 | labs( 66 | title = "US Grants", 67 | subtitle = "Percentage of US grants within each category", 68 | caption = caption 69 | ) + 70 | theme_void() + 71 | theme( 72 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 73 | plot.background = element_rect(fill = bg, colour = bg), 74 | plot.title = element_text(size = 160, hjust = 0.5, face = "bold"), 75 | plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 30)), 76 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 77 | plot.margin = margin(b = 80, t = 50, r = 50, l = 50), 78 | legend.position = "none", 79 | strip.text = element_blank() 80 | ) 81 | 82 | ggsave("scripts/2023/week-40-US-grants/us-grants.png", height = 18, width = 14) 83 | 84 | -------------------------------------------------------------------------------- /scripts/2023/week-40-US-grants/us-grants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-40-US-grants/us-grants.png -------------------------------------------------------------------------------- /scripts/2023/week-41-haunted-places/haunted-places-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-41-haunted-places/haunted-places-s.png -------------------------------------------------------------------------------- /scripts/2023/week-41-haunted-places/haunted-places.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-41-haunted-places/haunted-places.png -------------------------------------------------------------------------------- /scripts/2023/week-42-taylor-swift/eras-tour-set-list.txt: -------------------------------------------------------------------------------- 1 | track_name 2 | Miss Americana & The Heartbreak Prince 3 | Cruel Summer 4 | The Man 5 | You Need To Calm Down 6 | Lover 7 | The Archer 8 | Fearless (Taylor's Version) 9 | You Belong With Me (Taylor's Version) 10 | Love Story (Taylor's Version) 11 | 'tis the damn season 12 | willow 13 | marjorie 14 | champagne problems 15 | tolerate it 16 | ...Ready For It? 17 | Delicate 18 | Don't Blame Me 19 | Look What You Made Me Do 20 | Enchanted 21 | Long Live 22 | 22 (Taylor's Version) 23 | We Are Never Ever Getting Back Together (Taylor's Version) 24 | I Knew You Were Trouble (Taylor's Version) 25 | All Too Well (10 Minute Version) [Taylor's Version] [From The Vault] 26 | invisible string 27 | betty 28 | the last great american dynasty 29 | august 30 | illicit affairs 31 | my tears ricochet 32 | cardigan 33 | Style 34 | Blank Space 35 | Shake It Off 36 | Wildest Dreams 37 | Bad Blood 38 | Surprise Guitar Acoustic Song 39 | Surprise Piano Acoustic Song 40 | Lavender Haze 41 | Anti-Hero 42 | Midnight Rain 43 | Vigilante Shit 44 | Bejeweled 45 | Mastermind 46 | Karma 47 | -------------------------------------------------------------------------------- /scripts/2023/week-42-taylor-swift/taylor-swift-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-42-taylor-swift/taylor-swift-s.png -------------------------------------------------------------------------------- /scripts/2023/week-42-taylor-swift/taylor-swift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-42-taylor-swift/taylor-swift.png -------------------------------------------------------------------------------- /scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles-s.png -------------------------------------------------------------------------------- /scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | dat <- tidytuesdayR::tt_load(2023, week = 43) 13 | df <- dat$patient_risk_profiles |> 14 | clean_names() 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "grey20" 19 | bg <- "white" 20 | accent <- "grey20" 21 | pal <- c("bg", "black") 22 | 23 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 25 | font_add_google("Barlow", "bar") 26 | ft <- "bar" 27 | showtext_auto() 28 | 29 | # 🤼 wrangle ----------------------------------------------------------------- 30 | 31 | df_sex <- df |> 32 | select(person_id, starts_with("sex")) |> 33 | mutate(sex = ifelse(sex_female == 1, "Female", "Male")) |> 34 | select(person_id, sex) 35 | 36 | df_base <- df |> 37 | select(person_id, starts_with("age_group"), starts_with("predicted_risk")) |> 38 | pivot_longer(starts_with("age_group"), names_to = "age_group") |> 39 | filter(value == 1) |> 40 | select(-value) |> 41 | pivot_longer(starts_with("predicted_risk"), names_to = "risk") |> 42 | mutate( 43 | age_group = str_remove(age_group, "age_group_"), 44 | age_group = case_when( 45 | age_group == "0_4" ~ "00_04", 46 | age_group == "5_9" ~ "05-09", 47 | TRUE ~ age_group 48 | ), 49 | age_group = factor(age_group), 50 | risk = str_remove(risk, "predicted_risk_of_"), 51 | risk = str_replace_all(risk, "_", " "), 52 | risk = str_to_sentence(risk), 53 | risk = case_when( 54 | risk == "Acute pancreatitis with no chronic or hereditary or common causes of pancreatitis" ~ "Acute pancreatitis", 55 | risk == "Sudden vision loss with no eye pathology causes" ~ "Sudden vision loss", 56 | risk == "Sudden hearing loss no congenital anomaly or middle or inner ear conditions" ~ "Sudden hearing loss", 57 | risk == "Parkinsons disease inpatient or with 2nd diagnosis" ~ "Parkinsons disease", 58 | risk == "Treatment resistant depression trd" ~ "Treatment resistant depression", 59 | TRUE ~ risk 60 | ), 61 | risk = factor(risk) 62 | ) |> 63 | group_by(age_group, risk) |> 64 | summarise(mean = mean(value), .groups = "drop") |> 65 | mutate( 66 | risk_pct = to_pct(mean, 2) 67 | ) |> 68 | ungroup() |> 69 | mutate( 70 | x = as.numeric(age_group), 71 | y = -as.numeric(risk), 72 | val = min_max(mean, 1, 24) 73 | ) 74 | 75 | df_seg <- df_base |> 76 | group_by(risk) |> 77 | filter(x == min(x) | x == max(x)) |> 78 | select(-mean, -risk_pct) |> 79 | pivot_wider(id_cols = risk, names_from = age_group, values_from = x) |> 80 | clean_names() 81 | 82 | # 🔡 text -------------------------------------------------------------------- 83 | 84 | caption <- make_caption(accent) 85 | 86 | xlabs <- tribble( 87 | ~x, ~y, ~lab, 88 | 1, 0, "0", 89 | 10, 0, "Age", 90 | 19, 0, "95" 91 | ) 92 | 93 | # 📊 plot -------------------------------------------------------------------- 94 | 95 | df_base |> 96 | ggplot() + 97 | geom_text(aes(0, y, label = risk), family = ft, size = 16, colour = txt, hjust = 1, vjust = 1, fontface = "italic", nudge_y = 0.25) + 98 | geom_segment(aes(x = 1, xend = 19, y = 0, yend = 0), colour = txt, linewidth = 0.1) + 99 | geom_richtext(aes(x, y, label = lab), xlabs, family = ft, size = 12, colour = txt, fontface = "italic", label.colour = NA, fill = bg) + 100 | geom_point(aes(x, y, size = val, alpha = val), pch = 15) + 101 | scale_size_identity() + 102 | coord_fixed(clip = "off") + 103 | labs( 104 | caption = caption, 105 | fill = "Patient risk", 106 | title = "Patient Risk Profiles" 107 | ) + 108 | theme_void() + 109 | theme( 110 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 111 | plot.background = element_rect(fill = bg, colour = bg), 112 | plot.title = element_text(size = 128, hjust = 0.5, margin = margin(b = 30), face = "bold"), 113 | plot.subtitle = element_text(), 114 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 30)), 115 | plot.margin = margin(b = 70, t = 100, r = 100, l = 150), 116 | legend.position = "none" 117 | ) 118 | 119 | ggsave("scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles.png", height = 12, width = 18) 120 | 121 | -------------------------------------------------------------------------------- /scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles.png -------------------------------------------------------------------------------- /scripts/2023/week-44-horror-articles/horror-articles-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-44-horror-articles/horror-articles-s.png -------------------------------------------------------------------------------- /scripts/2023/week-44-horror-articles/horror-articles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-44-horror-articles/horror-articles.png -------------------------------------------------------------------------------- /scripts/2023/week-44-horror-articles/three-words.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-44-horror-articles/three-words.rds -------------------------------------------------------------------------------- /scripts/2023/week-45-house/house-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-45-house/house-s.png -------------------------------------------------------------------------------- /scripts/2023/week-45-house/house.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(geofacet) 10 | library(ggchicklet) 11 | library(ggfx) 12 | library(colorspace) 13 | 14 | # 💾 load data --------------------------------------------------------------- 15 | 16 | dat <- tidytuesdayR::tt_load(2023, week = 45) 17 | 18 | house <- dat$house 19 | 20 | # ✍️ fonts and palettes ------------------------------------------------------ 21 | 22 | txt <- "grey20" 23 | bg <- "white" 24 | accent <- "#00A95C" 25 | 26 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 27 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 28 | font_add_google("Barlow", "bar") 29 | font_add_google("Archivo Black", "ab") 30 | ft <- "bar" 31 | ft1 <- "ab" 32 | showtext_auto() 33 | 34 | # 🤼 wrangle ----------------------------------------------------------------- 35 | 36 | df_base <- house |> 37 | group_by(year, state) |> 38 | summarise( 39 | green_votes = sum(totalvotes[party == "GREEN"], na.rm = TRUE), 40 | total = sum(totalvotes, na.rm = TRUE), 41 | runoff = sum(runoff), 42 | special = sum(special), 43 | writein = sum(writein), 44 | .groups = "drop" 45 | ) |> 46 | mutate(state = str_to_title(state)) |> 47 | group_by(year) |> 48 | mutate( 49 | p = green_votes/total, 50 | pct = to_pct(p, 3), 51 | votes_lab = scales::comma(green_votes) 52 | ) 53 | 54 | df_2020 <- df_base |> 55 | filter(year == 2020) 56 | 57 | df_line <- df_base |> 58 | group_by(year) |> 59 | summarise( 60 | green_votes = sum(green_votes), 61 | total = sum(total), 62 | .groups = "drop" 63 | ) |> 64 | mutate(p = green_votes/total) 65 | 66 | # 🔡 text -------------------------------------------------------------------- 67 | 68 | caption <- make_caption(accent) 69 | 70 | subtitle <- "Total votes cast for the Green Party in 2020 71 | The Green Party received 3-4% of the votes between 2000-2016" 72 | 73 | # 📊 plot -------------------------------------------------------------------- 74 | 75 | g_base <- df_2020 |> 76 | ggplot() + 77 | with_shadow(geom_rrect(aes(xmin = 0, xmax = 1, ymin = 0, ymax = 1, fill = p), radius = grid::unit(9, "pt"))) + 78 | geom_text(aes(0.1, 0.9, label = str_wrap(state, 10)), family = ft, size = 10, colour = txt, hjust = 0, lineheight = 0.3, vjust = 1) + 79 | geom_text(aes(0.5, 0.35, label = pct), family = ft, size = 16, colour = txt) + 80 | geom_text(aes(0.5, 0.15, label = votes_lab), family = ft, size = 8, colour = txt) + 81 | facet_geo(~state) + 82 | scale_fill_gradient(low = "grey95", high = accent) + 83 | coord_fixed() + 84 | labs( 85 | title = "THE GREEN PARTY", 86 | subtitle = subtitle, 87 | caption = caption, 88 | ) + 89 | theme_void() + 90 | theme( 91 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 92 | plot.background = element_rect(fill = bg, colour = bg), 93 | plot.title = element_text(size = 160, hjust = 0, colour = accent, face = "bold", family = ft1), 94 | plot.subtitle = element_text(hjust = 0), 95 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 80)), 96 | plot.margin = margin(b = 20, t = 50, r = 150, l = 50), 97 | strip.text = element_blank(), 98 | legend.position = "none" 99 | ) 100 | 101 | g_line <- df_line |> 102 | ggplot() + 103 | with_shadow(geom_area(aes(year, p), fill = accent), x_offset = -5, y_offset = -5) + 104 | scale_y_continuous(breaks = seq(0, 0.04, 0.01), labels = to_pct(seq(0, 0.04, 0.01), 2), position = "right") + 105 | labs( 106 | x = "Year" 107 | ) + 108 | theme_minimal() + 109 | theme( 110 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 111 | plot.background = element_rect(fill = bg, colour = bg), 112 | legend.position = "none", 113 | axis.title = element_blank() 114 | ) 115 | 116 | g_base + 117 | inset_element(g_line, left = 0.83, right = 1.1, top = 0.3, bottom = 0) 118 | 119 | ggsave("scripts/2023/week-45-house/house.png", height = 10, width = 14) 120 | 121 | -------------------------------------------------------------------------------- /scripts/2023/week-45-house/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-45-house/house.png -------------------------------------------------------------------------------- /scripts/2023/week-46-diwali/diwali-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-46-diwali/diwali-s.png -------------------------------------------------------------------------------- /scripts/2023/week-46-diwali/diwali.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-46-diwali/diwali.png -------------------------------------------------------------------------------- /scripts/2023/week-46-diwali/legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-46-diwali/legend.png -------------------------------------------------------------------------------- /scripts/2023/week-46-diwali/legend1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-46-diwali/legend1.png -------------------------------------------------------------------------------- /scripts/2023/week-47-rladies/rladies-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-47-rladies/rladies-s.png -------------------------------------------------------------------------------- /scripts/2023/week-47-rladies/rladies.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggimage) 10 | library(cropcircles) 11 | library(colorspace) 12 | library(eyedroppeR) 13 | 14 | # 💾 load data --------------------------------------------------------------- 15 | 16 | rladies_chapters <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-11-21/rladies_chapters.csv') 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | extract_pal(12, "https://rladies.org/images/logo.png") 21 | pal <- c('#2D1C2A', '#40263F', '#512A51', '#613161', '#713072', '#833C84', '#F0EFF1', '#D5D3D7', '#BBB8BF', '#A59FAA', '#918A96', '#795F79') 22 | 23 | txt <- "grey20" 24 | bg <- lighten("purple", 0.9) 25 | accent <- pal[6] 26 | 27 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 28 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 29 | font_add_google("Barlow", "bar") 30 | font_add_google("Josefin Sans", "jose") 31 | ft <- "bar" 32 | ft1 <- "jose" 33 | showtext_auto() 34 | 35 | # 🤼 wrangle ----------------------------------------------------------------- 36 | 37 | # logo 38 | crop_hex( 39 | "https://secure.meetupstatic.com/photos/event/8/d/7/b/600_466896219.jpeg", 40 | "scripts/2023/week-47-rladies/rladies-logo.png", 41 | border_size = 8, border_colour = pal[6], bg_fill = "white") 42 | 43 | df_base <- rladies_chapters |> 44 | count(year, location) 45 | 46 | df_year <- rladies_chapters |> 47 | count(year) 48 | 49 | tiles <- paste0("scripts/2023/week-47-rladies/", c("in-person.png", "online.png")) 50 | 51 | df_legend <- tibble( 52 | x = 2010, 53 | y = c(450, 300), 54 | lab = c("In person\nattendance", "Online\nattendance"), 55 | tiles = crop_square(tiles, border_size = 3) 56 | ) 57 | 58 | # 🔡 text -------------------------------------------------------------------- 59 | 60 | caption <- make_caption(accent) 61 | 62 | title <- "Ladies Chapter Events" 63 | subtitle <- "R-Ladies Global is an inspiring story of community, empowerment, 64 | and diversity in the field of data science. Founded by Gabriela de Queiroz, R-Ladies 65 | began as a grassroots movement with a simple mission: to promote gender diversity in 66 | the R programming community and provide a welcoming space for women and gender 67 | minorities to learn, collaborate, and excel in data science. All events were held in 68 | person until 2020 when attendance also become virtual. Assuming this was largely 69 | influenced by COVID, but great it opened access for others." 70 | 71 | # 📊 plot -------------------------------------------------------------------- 72 | 73 | df_base |> 74 | ggplot() + 75 | geom_col_pattern( 76 | aes(x = year, y = n, pattern_filename = location), 77 | pattern = 'image', pattern_type = 'tile', fill = 'white', 78 | colour = 'black', pattern_filter = 'box', pattern_scale = 0.5 79 | ) + 80 | geom_text(aes(year, n + 10, label = n), df_year, family = ft, colour = txt, size = 16, vjust = 0) + 81 | geom_image(aes(x, y, image = tiles), df_legend, size = 0.12) + 82 | geom_text(aes(2011, y, label = lab), df_legend, family = ft, colour = txt, size = 20, hjust = 0, lineheight = 0.3) + 83 | annotate("text", x = 2010.9, y = 1025, label = title, family = ft1, colour = pal[6], size = 56, hjust = 0, lineheight = 0.25, fontface = "bold", vjust = 1) + 84 | annotate("text", x = 2009, y = 850, label = str_wrap(subtitle, 80), family = ft, colour = txt, size = 16, hjust = 0, lineheight = 0.3, vjust = 1) + 85 | geom_image(aes(2009.7, 1000, image = "scripts/2023/week-47-rladies/rladies-logo.png"), size = 0.15) + 86 | scale_pattern_filename_discrete(choices = tiles) + 87 | scale_x_continuous(breaks = 2012:2023, labels = 2012:2023, limits = c(2008, NA)) + 88 | coord_cartesian(clip = "off") + 89 | labs(caption = caption) + 90 | theme_void() + 91 | theme( 92 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 93 | plot.background = element_rect(fill = bg, colour = bg), 94 | plot.title = element_text(size = 128, hjust = 0.5), 95 | plot.subtitle = element_text(), 96 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 97 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 98 | axis.text.x = element_text(), 99 | legend.position = "none" 100 | ) 101 | 102 | ggsave("scripts/2023/week-47-rladies/rladies.png", height = 12, width = 17) 103 | 104 | -------------------------------------------------------------------------------- /scripts/2023/week-47-rladies/rladies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-47-rladies/rladies.png -------------------------------------------------------------------------------- /scripts/2023/week-48-dr-who/dr-who-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-48-dr-who/dr-who-s.png -------------------------------------------------------------------------------- /scripts/2023/week-48-dr-who/dr-who.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-48-dr-who/dr-who.png -------------------------------------------------------------------------------- /scripts/2023/week-49-life-expectancy/life-expectancy-aus-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-life-expectancy/life-expectancy-aus-s.png -------------------------------------------------------------------------------- /scripts/2023/week-49-life-expectancy/life-expectancy-aus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-life-expectancy/life-expectancy-aus.png -------------------------------------------------------------------------------- /scripts/2023/week-49-life-expectancy/life-expectancy-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-life-expectancy/life-expectancy-s.png -------------------------------------------------------------------------------- /scripts/2023/week-49-life-expectancy/life-expectancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-life-expectancy/life-expectancy.png -------------------------------------------------------------------------------- /scripts/2023/week-49-traffic/traffic-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-traffic/traffic-s.png -------------------------------------------------------------------------------- /scripts/2023/week-49-traffic/traffic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-49-traffic/traffic.png -------------------------------------------------------------------------------- /scripts/2023/week-50-christmas-movies/christmas-movies-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-50-christmas-movies/christmas-movies-s.png -------------------------------------------------------------------------------- /scripts/2023/week-50-christmas-movies/christmas-movies.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggfx) 10 | library(ggforce) 11 | library(ggimage) 12 | 13 | # 💾 load data --------------------------------------------------------------- 14 | 15 | dat <- tidytuesdayR::tt_load(2023, week = 50) 16 | movies <- dat$holiday_movies 17 | 18 | pal_xmas <- c('#1d463e', '#277d58', '#fec544', '#f05253', '#d1383a') 19 | 20 | # ✍️ fonts and palettes ------------------------------------------------------ 21 | 22 | txt <- "grey20" 23 | bg <- "white" 24 | accent <- "grey20" 25 | 26 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 27 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 28 | font_add("xmas", regular = "assets/fonts/christmas_dream/Christmas Dream.ttf") 29 | font_add_google("Barlow", "bar") 30 | font_add_google("Barlow", "bar700", regular.wt = 700) 31 | ft <- "bar" 32 | ft700 <- "bar700" 33 | ft_title <- "xmas" 34 | showtext_auto() 35 | 36 | # 🤼 wrangle ----------------------------------------------------------------- 37 | 38 | 39 | df_base <- movies |> 40 | slice_max(num_votes, n = 20) |> 41 | mutate( 42 | d_mins = runtime_minutes - mean(runtime_minutes), 43 | d_rating = average_rating - mean(average_rating), 44 | std_rating = min_max(1/average_rating, 0, 0.5), 45 | x = runif(n(), 0.5-std_rating, 0.5+std_rating), 46 | y_text = breathing_space_on_y(average_rating, 0.1), 47 | cat = case_when( 48 | christmas ~ "Christmas", 49 | holiday ~ "Holiday", 50 | all(christmas, holiday) ~ "Christmas and Holiday" 51 | ), 52 | genres = str_replace(genres, ",", ", "), 53 | details = glue("{year}, {runtime_minutes} mins, {genres}") 54 | ) 55 | 56 | # 🔡 text -------------------------------------------------------------------- 57 | 58 | caption <- make_caption(accent) 59 | 60 | # 📊 plot -------------------------------------------------------------------- 61 | 62 | df_base |> 63 | ggplot() + 64 | geom_image(aes(0.5, 6.7, image = "scripts/2023/week-50-christmas-movies/images/tree.png"), size = 1.2) + 65 | geom_segment(aes(x = 1.19, xend = x, y = y_text, yend = average_rating), linewidth = 0.2, colour = txt) + 66 | with_outer_glow( 67 | geom_point(aes(x, average_rating, size = num_votes, colour = cat)), 68 | colour = "black", 69 | sigma = 10 70 | ) + 71 | geom_point(aes(1.19, y_text), colour = txt) + 72 | geom_text(aes(1.2, y_text, label = primary_title), family = ft700, size = 12, colour = txt, hjust = 0, fontface = "italic") + 73 | geom_text(aes(1.2, y_text-0.045, label = details), family = ft, size = 8, colour = txt, hjust = 0, fontface = "italic") + 74 | geom_text(aes(x, average_rating, label = average_rating), family = ft700, size = 12, colour = txt, hjust = 0.1, fontface = "italic") + 75 | geom_segment(aes(x = 0, xend = 1.19, y = mean(movies$average_rating), yend = mean(movies$average_rating)), linetype = 2, linewidth = 0.6, colour = pal_xmas[2]) + 76 | annotate("text", x = 1.19, y = mean(movies$average_rating)+0.045, label = "Overall average", hjust = 1, family = ft, colour = pal_xmas[2], fontface = "italic", size = 12) + 77 | scale_size_binned(range = c(10, 25)) + 78 | scale_y_continuous(breaks = seq(5, 8.5, 0.5)) + 79 | scale_colour_manual(values = pal_xmas[c(3, 5)]) + 80 | xlim(0, 1.6) + 81 | coord_cartesian(clip = "off") + 82 | labs( 83 | title = "Christmas Movies", 84 | subtitle = "Looking for a good Christmas movie to watch? Here are the 20 most popular movies (the most votes) and their IMDb rating.", 85 | caption = caption, 86 | size = "Number of votes", 87 | colour = "Title contains...", 88 | y = "IMDb\nrating" 89 | ) + 90 | theme_void() + 91 | theme( 92 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 93 | plot.background = element_rect(fill = bg, colour = bg), 94 | plot.title = element_text(size = 256, hjust = 0.5, family = ft_title, face = "bold", colour = pal_xmas[5]), 95 | plot.subtitle = element_text(margin = margin(t = 15), hjust = 0.5), 96 | plot.caption = element_markdown(colour = txt, hjust = 1, margin = margin(t = 20)), 97 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 98 | axis.text.y = element_text(margin = margin(r = 10)), 99 | axis.ticks.y = element_line(linetype = 1, linewidth = 0.5), 100 | axis.ticks.length.y = unit(0.2, "cm"), 101 | axis.line.y = element_line(), 102 | axis.title.y = element_text(margin = margin(r = 10)) 103 | ) 104 | 105 | ggsave("scripts/2023/week-50-christmas-movies/christmas-movies.png", height = 12, width = 18) 106 | 107 | -------------------------------------------------------------------------------- /scripts/2023/week-50-christmas-movies/christmas-movies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-50-christmas-movies/christmas-movies.png -------------------------------------------------------------------------------- /scripts/2023/week-51-holiday-episodes/holiday-episodes-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-51-holiday-episodes/holiday-episodes-s.png -------------------------------------------------------------------------------- /scripts/2023/week-51-holiday-episodes/holiday-episodes.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggfx) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 51) 14 | episodes <- dat$holiday_episodes 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | the_simpsons <- c('#fccb00', '#1769b6', '#e44423', '#cddf8d', '#c6a168', '#54676a') 19 | txt <- "black" 20 | bg <- the_simpsons[1] 21 | accent <- txt 22 | 23 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 25 | font_add("simpsons", regular = "assets/fonts/the-simpsons/Simpsonfont DEMO.otf") 26 | font_add_google("Barlow", "bar") 27 | ft <- "simpsons" 28 | showtext_auto() 29 | 30 | # 🤼 wrangle ----------------------------------------------------------------- 31 | 32 | df_base <- episodes |> 33 | filter(str_detect(parent_primary_title, "Simpsons")) |> 34 | mutate(lab = paste0(str_wrap(primary_title, 15), "\n", average_rating)) 35 | 36 | # 🔡 text -------------------------------------------------------------------- 37 | 38 | caption <- make_caption(accent) 39 | 40 | # 📊 plot -------------------------------------------------------------------- 41 | 42 | df_base |> 43 | ggplot() + 44 | with_shadow(geom_point(aes(season_number, average_rating, size = num_votes), colour = the_simpsons[2]), colour = "black", x_offset = -10) + 45 | geom_text(aes(season_number, average_rating, label = lab), family = ft, colour = "grey10", size = 14, hjust = 0, lineheight = 0.3) + 46 | scale_size_binned(range = c(10, 30)) + 47 | coord_cartesian(clip = "off") + 48 | labs( 49 | title = "The Simpsons", 50 | subtitle = "holiday episodes", 51 | x = "Season", 52 | y = "IMDb\nrating", 53 | caption = caption 54 | ) + 55 | ylim(6, 9) + 56 | theme_void() + 57 | theme( 58 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 59 | plot.background = element_rect(fill = bg, colour = bg), 60 | plot.title = element_text(size = 256, hjust = 0.5, margin = margin(b = 15)), 61 | plot.subtitle = element_text(margin = margin(b = 15), hjust = 0.5, size = 96, face = "italic"), 62 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20), family = "bar"), 63 | axis.line = element_line(), 64 | axis.title = element_text(margin = margin(r = 15, t = 15)), 65 | axis.text = element_text(), 66 | axis.ticks = element_line(), 67 | axis.ticks.length = unit(0.2, "cm"), 68 | plot.margin = margin(b = 50, t = 50, r = 125, l = 50), 69 | legend.position = "none" 70 | ) 71 | 72 | ggsave("scripts/2023/week-51-holiday-episodes/holiday-episodes.png", height = 12, width = 12) 73 | -------------------------------------------------------------------------------- /scripts/2023/week-51-holiday-episodes/holiday-episodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-51-holiday-episodes/holiday-episodes.png -------------------------------------------------------------------------------- /scripts/2023/week-52-cran/cran-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-52-cran/cran-s.png -------------------------------------------------------------------------------- /scripts/2023/week-52-cran/cran.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggridges) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | dat <- tidytuesdayR::tt_load(2023, week = 52) 14 | cran <- dat$cran_20221122 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | txt <- "black" 19 | bg <- "white" 20 | accent <- txt 21 | 22 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 24 | font_add_google("Dosis", "dos") 25 | ft <- "dos" 26 | showtext_auto() 27 | 28 | # 🤼 wrangle ----------------------------------------------------------------- 29 | 30 | df_base <- cran |> 31 | mutate( 32 | pos1 = as.numeric(str_extract(version, "[:digit:]+")), 33 | log_loc_R = log(loc_R), 34 | f_pos1 = factor(pos1) 35 | ) |> 36 | filter( 37 | pos1 < 10, 38 | log_loc_R >= 0 39 | ) 40 | 41 | df_base_sum <- df_base |> 42 | group_by(f_pos1) |> 43 | summarise( 44 | n_packages = n_distinct(package), 45 | n_loc_R = sum(loc_R, na.rm = TRUE), 46 | mu_loc_R = mean(loc_R, na.rm = TRUE) 47 | ) |> 48 | mutate(lab = glue("{scales::comma(n_packages)} packages\n{scales::comma(n_loc_R)} total lines of code\n{scales::comma(mu_loc_R)} avg. lines of code per package")) 49 | 50 | # 🔡 text -------------------------------------------------------------------- 51 | 52 | caption <- make_caption(accent) 53 | 54 | # 📊 plot -------------------------------------------------------------------- 55 | 56 | df_base |> 57 | ggplot() + 58 | geom_density_ridges_gradient(aes(log_loc_R, f_pos1, fill = stat(x))) + 59 | geom_text(aes(-1, f_pos1, label = lab), df_base_sum, family = ft, colour = txt, size = 12, hjust = 0, lineheight = 0.3, vjust = -0.2) + 60 | scale_x_continuous(breaks = log(c(10, 1000, 10000, 100000)), labels = scales::comma(c(10, 1000, 10000, 100000))) + 61 | scale_fill_gradientn(colours = eyedroppeR::pencil_case$graffiti$div) + 62 | labs( 63 | title = "R Packages", 64 | subtitle = "The number of lines of code in the R folder by the package major version number. In general, the higher 65 | the version number the more code.", 66 | caption = caption, 67 | x = "Lines of code (log scale)", 68 | y = "Major\nversion\nnumber" 69 | ) + 70 | theme_void() + 71 | theme( 72 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 73 | plot.background = element_rect(fill = bg, colour = bg), 74 | plot.title = element_text(size = 256, hjust = 0.5, margin = margin(b = 15)), 75 | plot.subtitle = element_markdown(margin = margin(b = 15), hjust = 0.5, size = 64), 76 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 77 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 78 | axis.text = element_text(), 79 | axis.title = element_text(margin = margin(t = 15, r = 15)), 80 | axis.ticks.x = element_line(), 81 | axis.ticks.length.x = unit(0.2, "cm"), 82 | axis.line.x = element_line(), 83 | legend.position = "none" 84 | ) 85 | 86 | ggsave("scripts/2023/week-52-cran/cran.png", height = 18, width = 18) 87 | 88 | 89 | -------------------------------------------------------------------------------- /scripts/2023/week-52-cran/cran.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2023/week-52-cran/cran.png -------------------------------------------------------------------------------- /scripts/2024/week-48-border-control/border-control-final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-48-border-control/border-control-final.png -------------------------------------------------------------------------------- /scripts/2024/week-48-border-control/border-control.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(glue) 6 | library(ggtext) 7 | library(lubridate) 8 | 9 | # 💾 load data --------------------------------------------------------------- 10 | 11 | cbp_resp <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-11-26/cbp_resp.csv') 12 | cbp_state <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2024/2024-11-26/cbp_state.csv') 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | txt <- "grey20" 17 | txt <- "white" 18 | accent <- txt 19 | 20 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 21 | 22 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 23 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 24 | font_add_google("Poppins", "pop", regular.wt = 200) 25 | ft <- "pop" 26 | showtext_auto() 27 | 28 | # 🤼 wrangle ----------------------------------------------------------------- 29 | 30 | df <- cbp_resp |> 31 | mutate(date = ym(paste(fiscal_year, month_abbv))) |> 32 | group_by(date, land_border_region, encounter_type) |> 33 | summarise(n = sum(encounter_count)) |> 34 | mutate(land_border_region = factor(land_border_region, levels = c("Southwest Land Border", "Northern Land Border", "Other"))) |> 35 | ungroup() 36 | 37 | # 🔡 text -------------------------------------------------------------------- 38 | 39 | caption <- make_caption(accent) 40 | 41 | # 📊 plot -------------------------------------------------------------------- 42 | 43 | df |> 44 | ggplot() + 45 | geom_area(aes(date, n, fill = encounter_type)) + 46 | facet_wrap(~land_border_region, nrow = 1) + 47 | scale_y_continuous(breaks = seq(0, 3e5, 1e5), label = scales::comma(seq(0, 3e5, 1e5))) + 48 | scale_fill_manual(values = sunset[c(1, 3, 5)]) + 49 | labs( 50 | caption = caption, 51 | fill = "" 52 | ) + 53 | theme_void() + 54 | theme( 55 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 56 | plot.title = element_text(size = 128, hjust = 0.5), 57 | plot.subtitle = element_text(), 58 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 59 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 60 | axis.text = element_text(margin = margin(t = 10, r = 10, l = 10)), 61 | axis.line.x = element_line(colour = txt), 62 | axis.ticks.x = element_line(colour = txt), 63 | axis.ticks.length.x = unit(0.25, "cm"), 64 | legend.box.margin = margin(b = 20), 65 | legend.position = "top" 66 | ) 67 | 68 | ggsave("scripts/2024/week-48-border-control/border-control.png", height = 7, width = 12) 69 | -------------------------------------------------------------------------------- /scripts/2024/week-48-border-control/border-control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-48-border-control/border-control.png -------------------------------------------------------------------------------- /scripts/2024/week-49-traffic/traffic-final.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-49-traffic/traffic-final.pdf -------------------------------------------------------------------------------- /scripts/2024/week-49-traffic/traffic-final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-49-traffic/traffic-final.png -------------------------------------------------------------------------------- /scripts/2024/week-49-traffic/traffic.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | traffic <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2024/2024-12-03/A64_traffic.csv') |> 13 | clean_names() 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | txt <- "grey20" 18 | txt <- "white" 19 | accent <- txt 20 | bg <- "black" 21 | 22 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 23 | 24 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 25 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 26 | font_add_google("Poppins", "pop", regular.wt = 200) 27 | ft <- "pop" 28 | showtext_auto() 29 | 30 | # 🤼 wrangle ----------------------------------------------------------------- 31 | 32 | df_base <- traffic |> 33 | select(site_id, time_interval, 10:23) |> 34 | pivot_longer(cols = starts_with("x"), names_to = "speed", values_to = "volume") |> 35 | group_by(site_id, time_interval, speed) |> 36 | summarise(volume = sum(volume, na.rm = TRUE)) |> 37 | mutate( 38 | speed = case_when( 39 | speed == "x0_10_mph" ~ "<10 mph", 40 | speed == "x80_mph" ~ ">80 mph", 41 | TRUE ~ glue("{str_sub(speed, 2, 3)}-{str_sub(speed, 5, 6)} mph") 42 | ), 43 | speed = factor(speed, levels = rev(unique(speed))) 44 | ) |> 45 | ungroup() 46 | 47 | df_base |> 48 | group_by(site_id) |> 49 | summarise(volume = sum(volume)/31) 50 | 51 | # 🔡 text -------------------------------------------------------------------- 52 | 53 | caption <- make_caption(accent) 54 | 55 | x_labs <- c("12am", "6am", "12pm", "6pm") 56 | 57 | # 📊 plot -------------------------------------------------------------------- 58 | 59 | df_base |> 60 | ggplot() + 61 | geom_col(aes(time_interval, volume, fill = volume)) + 62 | facet_grid(speed ~ site_id) + 63 | scale_x_continuous(breaks = seq(0, 72, 24), labels = x_labs) + 64 | scale_fill_gradientn(colours = paletteer_d("rcartocolor::ag_GrnYl")) + 65 | labs(fill = "Volume") + 66 | coord_cartesian(clip = "off") + 67 | theme_void() + 68 | theme( 69 | text = element_text(family = ft, size = 64, lineheight = 0.3, colour = txt), 70 | # plot.background = element_rect(fill = bg), 71 | plot.title = element_text(size = 128, hjust = 0.5), 72 | plot.subtitle = element_text(), 73 | # plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 74 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 75 | axis.text.x = element_text(margin = margin(t = 10), size = 48), 76 | axis.line.x = element_line(colour = txt), 77 | axis.ticks = element_line(colour = txt), 78 | axis.ticks.length.x = unit(0.25, "cm"), 79 | legend.position = "left", 80 | legend.title = element_text(margin = margin(b = 10), face = "bold") 81 | ) 82 | 83 | ggsave("scripts/2024/week-49-traffic/traffic.png", height = 12, width = 18) 84 | 85 | 86 | -------------------------------------------------------------------------------- /scripts/2024/week-49-traffic/traffic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-49-traffic/traffic.png -------------------------------------------------------------------------------- /scripts/2024/week-49-traffic/traffic.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-49-traffic/traffic.pptx -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/bottle-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/bottle-image.png -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/brands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/brands.png -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/perfume-final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/perfume-final.png -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/perfume.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | # 4 | 5 | library(tidyverse) 6 | library(showtext) 7 | library(patchwork) 8 | library(janitor) 9 | library(glue) 10 | library(ggtext) 11 | library(ggwordcloud) 12 | 13 | # 💾 load data --------------------------------------------------------------- 14 | 15 | df <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2024/2024-12-10/parfumo_data_clean.csv') |> 16 | clean_names() 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | txt <- "grey20" 21 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 22 | perfume <- c("#EDE3E1", "#F3D9D7", "#F8CFCF", "#FCD7D8", "#FDE1E1", "#FCEBE9") 23 | font_add_google("Poppins", "pop", regular.wt = 200) 24 | ft <- "pop" 25 | pal <- perfume 26 | bg <- pal[3] 27 | showtext_auto() 28 | 29 | # 🤼 wrangle ----------------------------------------------------------------- 30 | 31 | make_word_df <- function(df, x) { 32 | tibble( 33 | word = str_split(df[x], ", ") |> 34 | reduce(c), 35 | category = x 36 | ) 37 | } 38 | 39 | clean_brands <- function(x) { 40 | 41 | id <- str_detect(x, "/") 42 | 43 | ifelse( 44 | id, 45 | str_extract(x, ".+/") |> 46 | str_remove_all("/") |> 47 | str_trim(), 48 | x 49 | ) 50 | 51 | } 52 | 53 | categories <- c("main_accords", "top_notes", "middle_notes", "base_notes") 54 | 55 | df_top_n <- df |> 56 | filter(rating_count > 100) |> 57 | arrange(desc(rating_value)) |> 58 | slice_head(n = 50) 59 | 60 | df_word <- map_dfr(categories, ~make_word_df(df_top_n, .x)) |> 61 | filter(!is.na(word)) |> 62 | mutate( 63 | word = str_remove_all(word, '"'), 64 | word = str_remove_all(word, '\\n'), 65 | word = tolower(word) 66 | ) |> 67 | count(category, word) |> 68 | mutate( 69 | word = str_to_sentence(word), 70 | category = factor(category, levels = rev(c("main_accords", "base_notes", "middle_notes", "top_notes"))) 71 | ) |> 72 | arrange(category, desc(n)) |> 73 | group_by(category) |> 74 | slice_head(n = 50) 75 | 76 | # 🔡 text -------------------------------------------------------------------- 77 | 78 | 79 | # 📊 plot -------------------------------------------------------------------- 80 | 81 | df_word |> 82 | ggplot() + 83 | geom_text_wordcloud(aes(label = word, size = n), family = ft, shape = "triangle-forward") + 84 | scale_size_area(max_size = 60) + 85 | facet_wrap(~category, ncol = 1) + 86 | theme_void() + 87 | theme( 88 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 89 | # plot.background = element_rect(fill = bg, colour = bg), 90 | plot.title = element_text(size = 128, hjust = 0.5), 91 | plot.subtitle = element_text(), 92 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 93 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 94 | strip.text = element_blank() 95 | ) 96 | 97 | # save -------------------------------------------------------------------- 98 | 99 | ggsave("scripts/2024/week-50-perfume/perfume.png", height = 16, width = 12) 100 | 101 | # bar chart of brands ----------------------------------------------------- 102 | 103 | df |> 104 | count(brand) |> 105 | mutate( 106 | brand = clean_brands(brand), 107 | brand = fct_reorder(brand, n) 108 | ) |> 109 | arrange(desc(n)) |> 110 | slice_head(n = 30) |> 111 | ggplot() + 112 | geom_col(aes(brand, n), fill = txt) + 113 | scale_y_continuous(position = "right") + 114 | coord_flip() + 115 | theme_void() + 116 | theme( 117 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 118 | # plot.background = element_rect(fill = bg, colour = bg), 119 | plot.title = element_text(size = 128, hjust = 0.5), 120 | plot.subtitle = element_text(), 121 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 122 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 123 | strip.text = element_blank(), 124 | axis.text.y = element_text(hjust = 1), 125 | axis.line.x = element_line(), 126 | axis.ticks = element_line(), 127 | axis.ticks.length.x = unit(0.25, "cm"), 128 | axis.text = element_text() 129 | ) 130 | 131 | # save -------------------------------------------------------------------- 132 | 133 | ggsave("scripts/2024/week-50-perfume/brands.png", height = 12, width = 10) 134 | 135 | -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/perfume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/perfume.png -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/perfume.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/perfume.pptx -------------------------------------------------------------------------------- /scripts/2024/week-50-perfume/words.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2024/week-50-perfume/words.png -------------------------------------------------------------------------------- /scripts/2025/01 - BYOD/predator-s.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/01 - BYOD/predator-s.jpg -------------------------------------------------------------------------------- /scripts/2025/01 - BYOD/predator.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/01 - BYOD/predator.jpg -------------------------------------------------------------------------------- /scripts/2025/02 - posit-conf/posit-conf-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/02 - posit-conf/posit-conf-s.png -------------------------------------------------------------------------------- /scripts/2025/02 - posit-conf/posit-conf.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggchicklet) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | conf2023 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-14/conf2023.csv') 14 | conf2024 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-14/conf2024.csv') 15 | 16 | # ✍️ fonts and palettes ------------------------------------------------------ 17 | 18 | 19 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 20 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 21 | 22 | txt <- "grey20" 23 | bg <- "white" 24 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 25 | font_add_google("Poppins", "pop", regular.wt = 200) 26 | ft <- "pop" 27 | showtext_auto() 28 | 29 | # 🚙 functions --------------------------------------------------------------- 30 | 31 | first_name <- function(x) { 32 | str_sub(x, 1, 1) 33 | } 34 | 35 | last_name <- function(x) { 36 | map_chr(x, ~{ 37 | str_split_1(.x, " ") |> 38 | tail(1) |> 39 | str_sub(1,1) 40 | }) 41 | } 42 | 43 | # 🤼 wrangle ----------------------------------------------------------------- 44 | 45 | df <- conf2023 |> 46 | mutate(year = 2023) |> 47 | bind_rows( 48 | conf2024 |> 49 | mutate(year = 2024) 50 | ) |> 51 | select(year, speaker_name) |> 52 | mutate( 53 | `First name` = first_name(speaker_name), 54 | `Last name` = last_name(speaker_name) 55 | ) |> 56 | select(-speaker_name) |> 57 | pivot_longer(-year, names_to = "name", values_to = "val") |> 58 | group_by(year, name, val) |> 59 | mutate(n = 1:n()) 60 | 61 | # 🔡 text -------------------------------------------------------------------- 62 | 63 | caption <- make_caption(txt) 64 | title <- "posit::conf()" 65 | subtitle <- str_wrap("Distribution of the first letter of the speaker's first and last name. 66 | 2023 was the year of the J's and M's. 2024 was the year of the A's. There has yet 67 | to be a speaker with a name starting with a Q, X, or Y.", 110) 68 | 69 | # 📊 plot -------------------------------------------------------------------- 70 | 71 | expand_grid( 72 | year = c(2023, 2024), 73 | name = c("First name", "Last name"), 74 | val = LETTERS 75 | ) |> 76 | left_join(df, join_by(year, name, val)) |> 77 | ggplot() + 78 | geom_tile(aes(val, n, fill = n), width = 0.9, height = 0.9) + 79 | scale_fill_gradientn(colours = sunset) + 80 | facet_grid(year ~ name) + 81 | labs( 82 | title = title, 83 | subtitle = subtitle, 84 | caption = caption 85 | ) + 86 | theme_void() + 87 | theme( 88 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 89 | plot.background = element_rect(fill = bg, colour = NA), 90 | plot.title = element_text(size = 128, hjust = 0.5, face = "bold", margin = margin(b = 10)), 91 | plot.subtitle = element_text(hjust = 0, margin = margin(b = 20), size = 48), 92 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 93 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 94 | legend.position = "none", 95 | panel.spacing = unit(1, "cm"), 96 | axis.text.x = element_text(margin = margin(t = 5)), 97 | strip.text = element_text(size = 48) 98 | ) 99 | 100 | ggsave("scripts/2025/02-posit-conf/posit-conf.png", height = 10, width = 12) 101 | 102 | -------------------------------------------------------------------------------- /scripts/2025/02 - posit-conf/posit-conf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/02 - posit-conf/posit-conf.png -------------------------------------------------------------------------------- /scripts/2025/03 - himalaya/himalaya final-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/03 - himalaya/himalaya final-s.png -------------------------------------------------------------------------------- /scripts/2025/03 - himalaya/himalaya final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/03 - himalaya/himalaya final.png -------------------------------------------------------------------------------- /scripts/2025/03 - himalaya/himalaya template.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/03 - himalaya/himalaya template.pptx -------------------------------------------------------------------------------- /scripts/2025/03 - himalaya/himalaya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/03 - himalaya/himalaya.png -------------------------------------------------------------------------------- /scripts/2025/04 - water security/water security-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/04 - water security/water security-s.png -------------------------------------------------------------------------------- /scripts/2025/04 - water security/water security.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/04 - water security/water security.png -------------------------------------------------------------------------------- /scripts/2025/04 - water security/water-security.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | water_insecurity_2022 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-28/water_insecurity_2022.csv') 13 | water_insecurity_2023 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-28/water_insecurity_2023.csv') 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 18 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 19 | 20 | txt <- "white" 21 | accent <- txt 22 | bg <- "grey20" 23 | bg1 <- "grey20" 24 | bg2 <- "grey10" 25 | line <- "grey30" 26 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 27 | pal <- c("#ee4266", "#3bceac") 28 | 29 | font_add_google("Poppins", "pop", regular.wt = 200) 30 | ft <- "pop" 31 | showtext_auto() 32 | 33 | # 🚙 functions --------------------------------------------------------------- 34 | 35 | 36 | 37 | # 🤼 wrangle ----------------------------------------------------------------- 38 | 39 | df <- water_insecurity_2022 |> 40 | bind_rows(water_insecurity_2023) |> 41 | mutate(state = str_extract(name, "(?<=,[:space:]).*")) |> 42 | filter(!state %in% c("Puerto Rico", "District of Columbia")) |> 43 | group_by(year, state) |> 44 | summarise( 45 | total_pop = sum(total_pop, na.rm = TRUE), 46 | plumbing = sum(plumbing, na.rm = TRUE) 47 | ) |> 48 | group_by(state) |> 49 | mutate( 50 | increasing = plumbing[year == 2022] < plumbing[year == 2023], 51 | order = plumbing[year == 2022] + increasing*1e6 52 | ) |> 53 | ungroup() |> 54 | mutate(state = fct_reorder(state, order, min)) 55 | 56 | df_labs <- df |> 57 | filter(year == 2022) |> 58 | distinct(state, plumbing) 59 | 60 | df_increasing <- df |> 61 | distinct(state, increasing) |> 62 | mutate(col = pal[increasing+1]) 63 | 64 | # 🔡 text -------------------------------------------------------------------- 65 | 66 | caption <- make_caption(c(txt, sunset[c(2, 5)]), bg) 67 | scale_x <- seq(0, 25000, 2500) 68 | subtitle <- "Water insecurity can be influenced by number of social vulnerability 69 | indicators from demographic characteristics to living conditions and socioeconomic 70 | status that vary spatially across the US. Plumbing facilities are improving in 22 71 | states and it is getting worse in 28." 72 | title <- "US Water Insecurity" 73 | 74 | df_text <- tibble( 75 | x = 10000, 76 | y = factor(c("Connecticut", "Alaska")), 77 | increasing = c(FALSE, TRUE), 78 | text = str_wrap(c("Plumbing facilities are improving", "Plumbing facilities are getting worse"), 10) 79 | ) 80 | 81 | # 📊 plot -------------------------------------------------------------------- 82 | 83 | df |> 84 | ggplot() + 85 | geom_line(aes(x = plumbing, y = state), colour = txt) + 86 | geom_point(aes(x = plumbing, y = state, colour = as.factor(year)), size = 6) + 87 | geom_text(aes(x, y, label = text), df_text, family = ft, size = 48, hjust = 0, vjust = 1, lineheight = 0.25, fontface = "bold", colour = rev(pal)) + 88 | scale_x_continuous(breaks = scale_x, labels = paste0(scale_x/1000, "k")) + 89 | scale_colour_manual(values = sunset[c(2, 5)]) + 90 | facet_wrap(~increasing, nrow = 1, scales = "free_y") + 91 | labs( 92 | caption = caption, 93 | colour = "", 94 | x = "US households lacking plumbing facilities", 95 | title = title, 96 | subtitle = str_wrap(subtitle, 150) 97 | ) + 98 | theme_void() + 99 | theme( 100 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 101 | plot.background = element_rect(fill = grid::radialGradient(c(bg1, bg2)), colour = bg), 102 | plot.title = element_text(size = 128, hjust = 0, face = "bold"), 103 | plot.subtitle = element_text(hjust = 0, margin = margin(t = 10, b = 10)), 104 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 105 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 106 | legend.position = "top", 107 | axis.text = element_text(hjust = 1, margin = margin(r = 5)), 108 | axis.text.x = element_text(hjust = 1, margin = margin(t = 10, b = 10)), 109 | axis.title.x = element_text(face = "bold"), 110 | panel.grid.major.y = element_line(linewidth = 0.5, linetype = 3, colour = line), 111 | panel.spacing = unit(1, "inches"), 112 | strip.text = element_blank() 113 | ) 114 | 115 | ggsave("scripts/2025/04 - water security/water security.png", height = 12, width = 20) 116 | 117 | -------------------------------------------------------------------------------- /scripts/2025/05 - simpsons/simpsons-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/05 - simpsons/simpsons-s.png -------------------------------------------------------------------------------- /scripts/2025/05 - simpsons/simpsons.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(shadowtext) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | simpsons_characters <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-04/simpsons_characters.csv') 14 | simpsons_episodes <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-04/simpsons_episodes.csv') 15 | simpsons_locations <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-04/simpsons_locations.csv') |> 16 | rename(location = normalized_name) 17 | simpsons_script_lines <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-04/simpsons_script_lines.csv') |> 18 | rename(words = normalized_text) 19 | 20 | 21 | # ✍️ fonts and palettes ------------------------------------------------------ 22 | 23 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 24 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 25 | font_add("simpsons", regular = "assets/fonts/the-simpsons/Simpsonfont DEMO.otf") 26 | 27 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 28 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 29 | simpsons <- c('#fad225', '#0388f4', '#fdfdfb', '#392d12') 30 | 31 | txt <- simpsons[1] 32 | bg <- simpsons[2] 33 | accent <- txt 34 | 35 | font_add_google("Poppins", "pop", regular.wt = 200) 36 | ft <- "pop" 37 | ft1 <- "simpsons" 38 | showtext_auto() 39 | 40 | # 🤼 wrangle ----------------------------------------------------------------- 41 | 42 | .n <- 12 43 | 44 | df_words <- simpsons_script_lines |> 45 | count(words, sort = TRUE) |> 46 | drop_na() |> 47 | head(.n) |> 48 | 49 | df_location <- simpsons_script_lines |> 50 | left_join(simpsons_locations, join_by(location_id == id)) |> 51 | count(location, sort = TRUE) |> 52 | drop_na() |> 53 | head(.n) 54 | 55 | df <- simpsons_script_lines |> 56 | left_join(simpsons_locations, join_by(location_id == id)) |> 57 | semi_join(df_words, join_by(words)) |> 58 | semi_join(df_location, join_by(location)) |> 59 | count(location, words, sort = TRUE) 60 | 61 | 62 | # 🔡 text -------------------------------------------------------------------- 63 | 64 | caption <- make_caption(simpsons[4], simpsons[3]) 65 | title <- "THE SIMPSONS" 66 | subtitle <- glue("The top {.n} most spoken phrases in the most referrenced locations") 67 | 68 | # 📊 plot -------------------------------------------------------------------- 69 | 70 | df |> 71 | mutate(location = str_wrap(location, 10)) |> 72 | ggplot() + 73 | geom_shadowtext(aes(location, words, label = str_to_sentence(words), size = 4*n+12), family = ft1, colour = txt, angle = rnorm(nrow(df), 360, 5)) + 74 | scale_x_discrete(position = "top") + 75 | scale_size_identity() + 76 | labs( 77 | title = title, 78 | subtitle = subtitle, 79 | caption = caption 80 | ) + 81 | coord_cartesian(clip = "off") + 82 | theme_void() + 83 | theme( 84 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = simpsons[3]), 85 | plot.background = element_rect(fill = grid::linearGradient( 86 | colours = simpsons[2:3], 87 | x1 = unit(0, "npc"), 88 | y1 = unit(1, "npc"), 89 | x2 = unit(0, "npc"), 90 | y2 = unit(0, "npc"))), 91 | plot.title = element_shadowtext(size = 220, hjust = 0.5, family = ft1, margin = margin(b = 20)), 92 | plot.subtitle = element_text(margin = margin(b = 50, t = 40), hjust = 0.5), 93 | plot.caption = element_markdown(colour = simpsons[4], hjust = 0.5, margin = margin(t = 20)), 94 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 95 | 96 | axis.text.x = element_shadowtext(colour = simpsons[3], family = ft1, margin = margin(b = 20)), 97 | legend.position = "bottom" 98 | ) 99 | 100 | ggsave("scripts/2025/05 - simpsons/simpsons.png", height = 12, width = 16) 101 | -------------------------------------------------------------------------------- /scripts/2025/05 - simpsons/simpsons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/05 - simpsons/simpsons.png -------------------------------------------------------------------------------- /scripts/2025/06 - cdc-datasets/cdc-datasets-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/06 - cdc-datasets/cdc-datasets-s.png -------------------------------------------------------------------------------- /scripts/2025/06 - cdc-datasets/cdc-datasets.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggbrick) 10 | 11 | # 💾 load data --------------------------------------------------------------- 12 | 13 | cdc_datasets <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-11/cdc_datasets.csv') 14 | fpi_codes <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-11/fpi_codes.csv') 15 | omb_codes <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-11/omb_codes.csv') 16 | 17 | # ✍️ fonts and palettes ------------------------------------------------------ 18 | 19 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 20 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 21 | 22 | txt <- "white" 23 | bg <- "black" 24 | accent <- txt 25 | pal <- eyedroppeR::pencil_case$d10$cat 26 | 27 | font_add_google("Poppins", "pop", regular.wt = 200) 28 | ft <- "pop" 29 | showtext_auto() 30 | 31 | # 🚙 functions --------------------------------------------------------------- 32 | 33 | # 🤼 wrangle ----------------------------------------------------------------- 34 | 35 | df <- cdc_datasets |> 36 | left_join(fpi_codes, join_by(program_code == program_code_pod_format)) |> 37 | count(program_name, sort = TRUE) |> 38 | mutate(p = n/sum(n)) |> 39 | drop_na() |> 40 | mutate( 41 | program_name = str_wrap(program_name, 30), 42 | program_name = paste0(str_pad(as.numeric(fct_reorder(program_name, n)), pad = "0", width = 2), ". ", program_name) 43 | ) 44 | 45 | # 🔡 text -------------------------------------------------------------------- 46 | 47 | caption <- make_caption(accent, bg) 48 | 49 | # 📊 plot -------------------------------------------------------------------- 50 | 51 | df |> 52 | ggplot() + 53 | geom_brick(aes(0, n, fill = program_name), bricks_per_layer = 12, type = "random") + 54 | annotate("text", x = 0, y = 1260, label = "1,245", family = ft, colour = txt, size = 64, vjust = 0) + 55 | scale_fill_manual(values = pal) + 56 | labs( 57 | title = "Saved CDC Datasets", 58 | subtitle = str_wrap("The Trump administration has ordered agencies to purge their websites 59 | of any references to topics such as LGBTQ+ rights. An effort is underway to back up 60 | this publicly funded data before it is lost. This week's dataset contains metadata 61 | about CDC datasets backed up on archive.org.", 75), 62 | caption = caption, 63 | fill = "Program name" 64 | ) + 65 | coord_brick(bricks_per_layer = 12, clip = "off") + 66 | theme_void() + 67 | theme( 68 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 69 | plot.background = element_rect(fill = bg, colour = bg), 70 | plot.title = element_text(size = 128, hjust = 0, margin = margin(b = 10)), 71 | plot.subtitle = element_text(hjust = 0, margin = margin(b = 10)), 72 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 73 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 74 | legend.text = element_text(margin = margin(b = 5, l = 5, t = 5)), 75 | axis.line.x = element_line(colour = txt), 76 | legend.position = "right" 77 | ) 78 | 79 | ggsave("scripts/2025/06 - cdc-datasets/cdc-datasets.png", height = 20, width = 10) 80 | -------------------------------------------------------------------------------- /scripts/2025/06 - cdc-datasets/cdc-datasets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/06 - cdc-datasets/cdc-datasets.png -------------------------------------------------------------------------------- /scripts/2025/07 - agencies/agencies-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/07 - agencies/agencies-s.png -------------------------------------------------------------------------------- /scripts/2025/07 - agencies/agencies.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(mapdata) 10 | library(biscale) 11 | library(ggforce) 12 | 13 | # 💾 load data --------------------------------------------------------------- 14 | 15 | agencies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-18/agencies.csv') 16 | 17 | # ✍️ fonts and palettes ------------------------------------------------------ 18 | 19 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 20 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 21 | 22 | txt <- "white" 23 | bg <- "black" 24 | accent <- txt 25 | 26 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 27 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 28 | pal <- rev(eyedroppeR::pencil_case$bright$cat) 29 | pal <- rev(eyedroppeR::pencil_case$secret_of_mana$cat) 30 | pal <- sunset 31 | 32 | font_add_google("Poppins", "pop", regular.wt = 200) 33 | ft <- "pop" 34 | showtext_auto() 35 | 36 | # 🚙 functions --------------------------------------------------------------- 37 | 38 | 39 | 40 | # 🤼 wrangle ----------------------------------------------------------------- 41 | 42 | df_state <- map_data("county") 43 | 44 | df_base <- agencies |> 45 | filter( 46 | longitude < -10, 47 | longitude > -125 48 | ) |> 49 | mutate( 50 | county = tolower(county), 51 | county_split = str_split(county, ", ") 52 | ) |> 53 | unnest(county_split) |> 54 | group_by(county = county_split) |> 55 | summarise( 56 | p = mean(is_nibrs), 57 | n = sum(is_nibrs) 58 | ) 59 | 60 | df_base <- df_state |> 61 | left_join(df_base, join_by(subregion == county)) 62 | 63 | # 🔡 text -------------------------------------------------------------------- 64 | 65 | caption <- make_caption(accent, bg) 66 | title <- "Agencies on the FBI’s National Incident-Based Reporting System (NIBRS)" 67 | subtitle <- "Crime data is dynamic. Offenses occur, arrests are made, and property 68 | is recovered every day. The FBI’s Crime Data Explorer, the digital front door for 69 | UCR data, is an attempt to reflect that fluidity in crime. The data presented there 70 | is updated regularly in a way that UCR publications previously could not be. 71 | Launched in 2017, the CDE’s content and features are updated and expanded continuously. 72 | CDE enables law enforcement agencies, researchers, journalists, and the public to 73 | more easily use and understand the massive amounts of UCR data using charts and graphs." 74 | 75 | # 📊 plot -------------------------------------------------------------------- 76 | 77 | df_base |> 78 | ggplot() + 79 | geom_polygon(aes(long, lat, group = group, fill = n), colour = bg, linewidth = 0.1) + 80 | annotate("text", x = -124.6813, y = 25.13, label = "79%", family = ft, size = 128, colour = txt, hjust = 0, vjust = -0.2) + 81 | annotate("text", x = -124.6813, y = 24.9, label = "of agencies are on FBI’s National Incident-Based Reporting System (NIBRS).", family = ft, size = 16, colour = txt, hjust = 0) + 82 | scale_fill_gradientn(colours = pal) + 83 | coord_fixed() + 84 | labs( 85 | title = title, 86 | subtitle = str_wrap(subtitle, 200), 87 | caption = caption, 88 | fill = "Agency\ncount" 89 | ) + 90 | theme_void() + 91 | theme( 92 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 93 | plot.background = element_rect(fill = grid::radialGradient(c(bg, "grey20"), r1 = unit(0.5, "npc"))), 94 | plot.title = element_text(size = 128, hjust = 0.5, face = "bold"), 95 | plot.subtitle = element_text(hjust = 0.5), 96 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 97 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 98 | legend.position = "bottom" 99 | ) 100 | 101 | ggsave("scripts/2025/07 - agencies/agencies.png", height = 13.5, width = 24.5) 102 | -------------------------------------------------------------------------------- /scripts/2025/07 - agencies/agencies.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/07 - agencies/agencies.png -------------------------------------------------------------------------------- /scripts/2025/08 - academic literature/academic-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/08 - academic literature/academic-s.png -------------------------------------------------------------------------------- /scripts/2025/08 - academic literature/academic.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | article_dat <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-25/article_dat.csv') 13 | model_dat <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-02-25/model_dat.csv') 14 | 15 | # ✍️ fonts and palettes ------------------------------------------------------ 16 | 17 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 18 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 19 | 20 | txt <- "white" 21 | bg <- "grey10" 22 | bg1 <- "grey5" 23 | bg2 <- "grey20" 24 | accent <- txt 25 | 26 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 27 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 28 | 29 | font_add_google("Poppins", "pop", regular.wt = 200) 30 | ft <- "pop" 31 | showtext_auto() 32 | 33 | # 🤼 wrangle ----------------------------------------------------------------- 34 | 35 | df <- model_dat |> 36 | filter( 37 | lower != -99, 38 | upper != -99, 39 | measure == "OR" 40 | # compare %in% c("Hispanic", "Black", "Asian", "Other") 41 | ) 42 | 43 | df <- article_dat |> 44 | select( 45 | `Access to care` = access_to_care, 46 | `Disparities in received treatment` = treatment_received, 47 | `Disparities in health outcomes` = health_outcome, 48 | `Ovarian cancer` = cancer_ovarian, 49 | `Uterine cancer` = cancer_uterine, 50 | `Cervical cancer` = cancer_cervical, 51 | `Vulver cancer` = cancer_vulvar, 52 | `Other gynocological cancer` = other_gyn_onc, 53 | Endometriosis = endo, 54 | `Fibroids` = fibroids, 55 | `Other gynocologic surgery` = other_gyn_surg, 56 | Fertinility = fert, 57 | `Maternal morbidity and mortality` = matmorbmort, 58 | `Other pregnancy outcomes` = other_preg, 59 | `Physician diversity and/or training` = phys_div, 60 | COVID = covid 61 | ) |> 62 | pivot_longer(everything(), names_to = "var", values_to = "included") |> 63 | group_by(var) |> 64 | summarise( 65 | yes = mean(included, na.rm = TRUE), 66 | no = mean(included == 0, na.rm = TRUE) 67 | ) |> 68 | pivot_longer(-var, names_to = "included", values_to = "p") 69 | 70 | df_lab <- df |> 71 | filter(included == "yes") |> 72 | mutate(pct = paste0(round(p*100), "%")) 73 | 74 | # 🔡 text -------------------------------------------------------------------- 75 | 76 | caption <- make_caption(accent, bg) 77 | 78 | # 📊 plot -------------------------------------------------------------------- 79 | 80 | df |> 81 | ggplot() + 82 | geom_col(aes(3, p, fill = included)) + 83 | geom_text(aes(0, 0, label = pct), df_lab, family = ft, colour = txt, size = 24, vjust = 1.6) + 84 | geom_text(aes(1, 0, label = str_wrap(var, 14)), df_lab, family = ft, colour = txt, size = 10, lineheight = 0.3) + 85 | geom_segment(aes(x = 2.4, xend = 3.6, y = p, yend = p), filter(df, included == "yes"), colour = sunset[4]) + 86 | facet_wrap(~var) + 87 | scale_fill_manual(values = c(no = bg1, yes = sunset[4])) + 88 | ylim(0, 1) + 89 | xlim(0, 4) + 90 | coord_polar("y", clip = "off") + 91 | labs( 92 | title = "Academic Literature on Racial and Ethnic Disparities in\nReproductive Medicine in the US", 93 | subtitle = "The percentage of articles that addressed the given factor", 94 | caption = caption 95 | ) + 96 | theme_void() + 97 | theme( 98 | text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), 99 | plot.background = element_rect(fill = grid::radialGradient(c("grey25", "grey15"))), 100 | plot.title = element_text(size = 84, hjust = 0.5), 101 | plot.subtitle = element_text(hjust = 0.5), 102 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 103 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 104 | strip.text = element_blank(), 105 | legend.position = "none" 106 | ) 107 | 108 | ggsave("scripts/2025/08 - academic literature/academic.png", height = 12, width = 11) 109 | 110 | -------------------------------------------------------------------------------- /scripts/2025/08 - academic literature/academic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/08 - academic literature/academic.png -------------------------------------------------------------------------------- /scripts/2025/09 - long beach/long beach-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/09 - long beach/long beach-s.png -------------------------------------------------------------------------------- /scripts/2025/09 - long beach/long beach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/09 - long beach/long beach.png -------------------------------------------------------------------------------- /scripts/2025/10 - pixar/pixar-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/10 - pixar/pixar-s.png -------------------------------------------------------------------------------- /scripts/2025/10 - pixar/pixar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/10 - pixar/pixar.png -------------------------------------------------------------------------------- /scripts/2025/11-palm trees/palm-trees-gross-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/11-palm trees/palm-trees-gross-s.png -------------------------------------------------------------------------------- /scripts/2025/11-palm trees/palm-trees-gross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/11-palm trees/palm-trees-gross.png -------------------------------------------------------------------------------- /scripts/2025/11-palm trees/palm-trees-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/11-palm trees/palm-trees-s.png -------------------------------------------------------------------------------- /scripts/2025/11-palm trees/palm-trees.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | palmtrees <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-03-18/palmtrees.csv') 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 17 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 18 | 19 | pal1 <- c('#4484e5', '#4ec7ea', '#ddebe7', '#faf6ea', '#d9e1f3', '#a8aa42') 20 | pal2 <- c('#2c3510', '#334001', '#2d3a15', '#9f962d', '#f3f0e4', '#fcf9ee', '#77d4ed', '#3f83d7') 21 | 22 | txt <- "grey20" 23 | bg <- pal2[5] 24 | accent <- pal2[3] 25 | 26 | bg1 <- colorspace::darken(bg, 0.1) 27 | bg2 <- pal2[5] 28 | 29 | font_add_google("Raleway", "raleway", regular.wt = 200) 30 | ft <- "raleway" 31 | showtext_auto() 32 | 33 | # 🚙 functions --------------------------------------------------------------- 34 | 35 | 36 | # 🤼 wrangle ----------------------------------------------------------------- 37 | 38 | df <- palmtrees |> 39 | filter(max_stem_height_m > 0, max_stem_height_m <= 70) |> 40 | select(conspicuousness, max_leaf_number, max_stem_height_m) |> 41 | mutate(conspicuousness = str_to_title(conspicuousness)) |> 42 | drop_na() 43 | 44 | df_consp <- df |> 45 | distinct(conspicuousness) |> 46 | mutate( 47 | x = 60, 48 | y = 75 49 | ) 50 | 51 | # 🔡 text -------------------------------------------------------------------- 52 | 53 | caption <- make_caption(accent, pal2[4]) 54 | 55 | # 📊 plot -------------------------------------------------------------------- 56 | 57 | df |> 58 | ggplot(aes(max_stem_height_m, max_leaf_number)) + 59 | geom_point(alpha = 0.3, colour = pal2[3], pch = "/", size = 15) + 60 | geom_smooth(method = "lm", colour = pal2[4], fill = pal2[4]) + 61 | scale_x_continuous(breaks = seq(0, 60, 10), labels = paste0(seq(0, 60, 10), "m")) + 62 | scale_y_continuous(breaks = seq(0, 60, 10), labels = seq(0, 60, 10)) + 63 | coord_cartesian(clip = "off") + 64 | labs( 65 | title = "PALM TREES", 66 | subtitle = "On average, the taller the palm, the more leaves it has", 67 | caption = caption, 68 | x = "Max height", 69 | y = "Max leaves" 70 | ) + 71 | theme_void() + 72 | theme( 73 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 74 | plot.background = element_rect(fill = bg, colour = bg), 75 | plot.title = element_text(size = 128, hjust = 0.5, margin = margin(b = 20)), 76 | plot.subtitle = element_text(margin = margin(b = 40), hjust = 0.5), 77 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 60)), 78 | plot.margin = margin(b = 20, t = 50, r = 100, l = 50), 79 | panel.background = element_rect(fill = grid::radialGradient(colours = c(bg2, bg1)), colour = NA), 80 | strip.text = element_blank(), 81 | axis.text = element_text(margin = margin(r = 20, t = 20)), 82 | axis.title.x = element_text(margin = margin(t = 20)), 83 | axis.title.y = element_text(angle = 90, margin = margin(r = 20)) 84 | ) 85 | 86 | ggsave("scripts/2025/11-palm trees/palm-trees.png", height = 12, width = 12) 87 | -------------------------------------------------------------------------------- /scripts/2025/11-palm trees/palm-trees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/11-palm trees/palm-trees.png -------------------------------------------------------------------------------- /scripts/2025/12 - amazon/amazon-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/12 - amazon/amazon-s.png -------------------------------------------------------------------------------- /scripts/2025/12 - amazon/amazon.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | report_words_clean <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-03-25/report_words_clean.csv') 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 17 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 18 | 19 | txt <- "grey50" 20 | txt2 <- "grey10" 21 | bg <- "white" 22 | accent <- txt 23 | 24 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 25 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 26 | 27 | font_add_google("Raleway", "raleway", regular.wt = 200) 28 | font_add_google("Merriweather", "mw") 29 | ft <- "raleway" 30 | ft <- "mw" 31 | showtext_auto() 32 | 33 | # 🤼 wrangle ----------------------------------------------------------------- 34 | 35 | df <- report_words_clean |> 36 | slice_head(n = 20000) |> 37 | summarise(text = paste0(word, collapse = " ")) 38 | 39 | df_year <- report_words_clean |> 40 | count(year) 41 | 42 | df_ai <- report_words_clean |> 43 | group_by(year) |> 44 | summarise( 45 | n = sum(word %in% c("genai", "ai", "artificial")), 46 | total = n() 47 | ) |> 48 | ungroup() |> 49 | mutate(rate = round(n/total*1e4, 1)) |> 50 | filter(n > 0) 51 | 52 | # 🔡 text -------------------------------------------------------------------- 53 | 54 | caption <- make_caption(txt2, bg) 55 | 56 | title <- "References to 'AI'\nin Amazon's\nannual reports" 57 | subtitle <- "per 10,000 words. On average a report 58 | has 22,000 words (excluding stop words)" 59 | 60 | # 📊 plot -------------------------------------------------------------------- 61 | 62 | df |> 63 | ggplot() + 64 | geom_text(aes(2014, 10, label = str_wrap(text, 500)), family = ft, colour = txt, size = 4, lineheight = 0.3) + 65 | geom_col(aes(year, rate), df_ai, fill = "white", colour = txt2, width = 0.5, linewidth = 0.25) + 66 | geom_text(aes(year, rate + 0.5, label = rate), df_ai, family = ft, colour = txt2, size = 12, fontface = "bold", lineheight = 0.3) + 67 | annotate("text", x = 2010, y = 9, label = title, family = ft, size = 48, colour = txt2, lineheight = 0.3, fontface = "bold") + 68 | annotate("text", x = 2010, y = 6, label = subtitle, family = ft, size = 18, colour = txt2, lineheight = 0.3) + 69 | scale_x_continuous(breaks = 2005:2023, labels = 2005:2023, limits = c(2005, 2023.25)) + 70 | labs(caption = caption) + 71 | theme_void() + 72 | theme( 73 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 74 | plot.background = element_rect(fill = bg, colour = bg), 75 | plot.title = element_text(size = 128, hjust = 0.5), 76 | plot.subtitle = element_text(hjust = 0.5), 77 | plot.caption = element_markdown(colour = txt2, hjust = 0.5, margin = margin(t = 20)), 78 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 79 | axis.text.x = element_text(colour = txt2, size = 32), 80 | axis.line.x = element_line(), 81 | axis.ticks = element_line(), 82 | axis.ticks.length.x = unit(0.25, "cm") 83 | ) 84 | 85 | ggsave("scripts/2025/12 - amazon/amazon.png", height = 12, width = 12) 86 | -------------------------------------------------------------------------------- /scripts/2025/12 - amazon/amazon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/12 - amazon/amazon.png -------------------------------------------------------------------------------- /scripts/2025/13 - pokemon/pokemon-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/13 - pokemon/pokemon-s.png -------------------------------------------------------------------------------- /scripts/2025/13 - pokemon/pokemon-stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/13 - pokemon/pokemon-stats.png -------------------------------------------------------------------------------- /scripts/2025/13 - pokemon/pokemon-title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/13 - pokemon/pokemon-title.png -------------------------------------------------------------------------------- /scripts/2025/13 - pokemon/pokemon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/13 - pokemon/pokemon.png -------------------------------------------------------------------------------- /scripts/2025/14 - timely and effective care/care-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/14 - timely and effective care/care-s.png -------------------------------------------------------------------------------- /scripts/2025/14 - timely and effective care/care.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/14 - timely and effective care/care.png -------------------------------------------------------------------------------- /scripts/2025/15 - penguins/penguins-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/15 - penguins/penguins-s.png -------------------------------------------------------------------------------- /scripts/2025/15 - penguins/penguins.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(ggsankey) 10 | library(ggbeeswarm) 11 | library(cropcircles) 12 | 13 | # 💾 load data --------------------------------------------------------------- 14 | 15 | penguins <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-04-15/penguins.csv') 16 | penguins_raw <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-04-15/penguins_raw.csv') 17 | 18 | # ✍️ fonts and palettes ------------------------------------------------------ 19 | 20 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 21 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 22 | 23 | txt <- "grey20" 24 | bg <- "white" 25 | accent <- txt 26 | 27 | bg1 <- "white" 28 | bg2 <- "grey85" 29 | 30 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 31 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 32 | 33 | font_add_google("Raleway", "raleway", regular.wt = 200) 34 | ft <- "raleway" 35 | showtext_auto() 36 | 37 | img_url <- "https://allisonhorst.github.io/palmerpenguins/reference/figures/lter_penguins.png" 38 | 39 | pal <- c(Chinstrap = '#c25dca', Gentoo = '#0f7473', Adelie = '#ff7f03') 40 | 41 | # 🚙 functions --------------------------------------------------------------- 42 | 43 | 44 | 45 | # 🤼 wrangle ----------------------------------------------------------------- 46 | 47 | df <- penguins |> 48 | select(species, bill_len, bill_dep, flipper_len, body_mass) |> 49 | mutate(body_mass = body_mass/1000) |> 50 | drop_na() |> 51 | pivot_longer(-species) |> 52 | mutate( 53 | name = case_when( 54 | name == "bill_len" ~ "Bill length", 55 | name == "bill_dep" ~ "Bill depth", 56 | name == "flipper_len" ~ "Flipper length", 57 | name == "body_mass" ~ "Body mass" 58 | ) 59 | ) 60 | 61 | df_means <- df |> 62 | group_by(species, name) |> 63 | summarise( 64 | mean = mean(value) 65 | ) 66 | 67 | # 🔡 text -------------------------------------------------------------------- 68 | 69 | caption <- make_caption(accent, bg) 70 | 71 | # 📊 plot -------------------------------------------------------------------- 72 | 73 | df |> 74 | ggplot() + 75 | geom_boxplot(aes(value, species, colour = species, fill = species), alpha = 0.2, width = 0.5) + 76 | geom_beeswarm(aes(value, species, colour = species), size = 4, alpha = 0.5, cex = 1.5) + 77 | geom_richtext(aes(mean, species, label = round(mean, 1), colour = species), df_means, family = ft, size = 12, fill = bg, label.r = unit(0.3, "lines")) + 78 | facet_wrap(~name, scales = "free_x") + 79 | scale_colour_manual(values = pal) + 80 | scale_fill_manual(values = pal) + 81 | labs( 82 | title = glue('Palmer Penguins'),, 83 | subtitle = glue(''), 84 | caption = caption, 85 | colour = "Species" 86 | ) + 87 | coord_cartesian(clip = "off") + 88 | theme_void() + 89 | theme( 90 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 91 | plot.background = element_rect(fill = bg, colour = bg), 92 | plot.title = element_markdown(size = 128, hjust = 0.5, margin = margin(b = 0)), 93 | plot.subtitle = element_markdown(hjust = 0.5), 94 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 95 | plot.margin = margin(b = 20, t = 50, r = 50, l = 50), 96 | legend.position = "none", 97 | axis.text.x = element_text(margin = margin(t = 10)), 98 | axis.line.x = element_line(), 99 | axis.ticks.x = element_line(), 100 | axis.ticks.length.x = unit(0.25, "cm"), 101 | strip.background = element_rect(fill = txt), 102 | strip.text = element_text(colour = bg, margin = margin(t = 5, b = 5), size = 48), 103 | panel.background = element_rect(fill = grid::radialGradient(c(bg1, bg2)), colour = NA), 104 | legend.margin = margin(b = 20) 105 | ) 106 | 107 | ggsave("scripts/2025/15 - penguins/penguins.png", height = 14, width = 12) 108 | -------------------------------------------------------------------------------- /scripts/2025/15 - penguins/penguins.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/15 - penguins/penguins.png -------------------------------------------------------------------------------- /scripts/2025/16 - road fatalities/road fatalities-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/16 - road fatalities/road fatalities-s.png -------------------------------------------------------------------------------- /scripts/2025/16 - road fatalities/road fatalities.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | library(fable) 10 | library(fabletools) 11 | library(feasts) 12 | library(tsibble) 13 | 14 | # 💾 load data --------------------------------------------------------------- 15 | 16 | daily_accidents <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-04-22/daily_accidents.csv') 17 | daily_accidents_420 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-04-22/daily_accidents_420.csv') 18 | 19 | # ✍️ fonts and palettes ------------------------------------------------------ 20 | 21 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 22 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 23 | 24 | txt <- "grey20" 25 | bg <- "white" 26 | accent <- txt 27 | 28 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 29 | 30 | font_add_google("Raleway", "raleway", regular.wt = 200) 31 | ft <- "raleway" 32 | showtext_auto() 33 | 34 | # 🤼 wrangle ----------------------------------------------------------------- 35 | 36 | df <- daily_accidents |> 37 | mutate(date = ymd(glue("{year(date)}-{month(date)}-01"))) |> 38 | group_by(date) |> 39 | summarise(fatalities_count = sum(fatalities_count)) |> 40 | mutate( 41 | year = year(date), 42 | month = month(date), 43 | ym = yearmonth(paste(year(date), month(date))), 44 | series = "Actual" 45 | ) 46 | 47 | df_ts <- df |> 48 | as_tsibble(index = ym) 49 | 50 | mod <- df_ts |> 51 | filter(year <= 2006) |> 52 | model( 53 | TSLM(fatalities_count ~ trend() + season()) 54 | ) 55 | 56 | fcst <- forecast(mod, h = 120) 57 | 58 | df_base <- df |> 59 | bind_rows( 60 | fcst |> 61 | as_tibble() |> 62 | transmute( 63 | ym, 64 | fatalities_count = .mean, 65 | series = "Counterfactual" 66 | ) 67 | ) 68 | 69 | 70 | actual <- df |> 71 | filter(year > 2006) |> 72 | pull(fatalities_count) |> 73 | sum() 74 | 75 | sum(fcst$.mean) - actual 76 | 77 | # 🔡 text -------------------------------------------------------------------- 78 | 79 | caption <- make_caption(accent, bg) 80 | text <- str_wrap("Road safety initiates saved 141k lives", 30) 81 | 82 | # 📊 plot -------------------------------------------------------------------- 83 | 84 | df_base |> 85 | ggplot() + 86 | geom_vline(aes(xintercept = ymd("2007-01-01")), linetype = 3, linewidth = 1) + 87 | geom_line(aes(ym, fatalities_count, colour = series, linetype = series)) + 88 | annotate("text", x = ymd("2007-06-01"), y = 6000, label = text, family = ft, colour = txt, size = 16, hjust = 0, lineheight = 0.3) + 89 | scale_colour_manual(values = c(Actual = "grey20", Counterfactual = sunset[4])) + 90 | scale_y_continuous(breaks = seq(0, 8000, 500), labels = seq(0, 8000, 500)) + 91 | labs( 92 | title = "Fatal Car Crashes in the US", 93 | subtitle = str_wrap("In 2007, the United States saw a decrease in road fatalities, 94 | partly due to the early stages of the Great Recession and a corresponding 95 | decline in travel. Additionally, ongoing safety initiatives, such as seatbelt 96 | laws and Graduated Driver Licensing programs, were likely contributing factors. 97 | These initiatives saved approximately 141k lives from 2007 to 2016. The counterfactual 98 | estimates the fatalities assuming the initiatives weren't implemented", 130), 99 | caption = caption, 100 | colour = "Series", 101 | linetype = "Series" 102 | ) + 103 | coord_cartesian(clip = "off") + 104 | theme_void() + 105 | theme( 106 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 107 | plot.background = element_rect(fill = bg, colour = bg), 108 | plot.title = element_text(size = 128, hjust = 0, face = "bold", margin = margin(b = 30)), 109 | plot.subtitle = element_text(hjust = 0, margin = margin(b = 30)), 110 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), 111 | plot.margin = margin(b = 50, t = 80, r = 80, l = 80), 112 | axis.text = element_text(margin = margin(t = 10)), 113 | axis.line = element_line(), 114 | axis.ticks = element_line(), 115 | axis.ticks.length = unit(0.25, "cm"), 116 | panel.grid.major = element_line(colour = "grey95"), 117 | legend.position = "top" 118 | ) 119 | 120 | ggsave("scripts/2025/16 - road fatalities/road fatalities.png", height = 12, width = 16) 121 | -------------------------------------------------------------------------------- /scripts/2025/16 - road fatalities/road fatalities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/16 - road fatalities/road fatalities.png -------------------------------------------------------------------------------- /scripts/2025/19 - mount vesuvius/mount vesuvius-s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/19 - mount vesuvius/mount vesuvius-s.png -------------------------------------------------------------------------------- /scripts/2025/19 - mount vesuvius/mount vesuvius.R: -------------------------------------------------------------------------------- 1 | # https://github.com/rfordatascience/tidytuesday 2 | 3 | library(tidyverse) 4 | library(showtext) 5 | library(patchwork) 6 | library(janitor) 7 | library(glue) 8 | library(ggtext) 9 | 10 | # 💾 load data --------------------------------------------------------------- 11 | 12 | vesuvius <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-05-13/vesuvius.csv') 13 | 14 | # ✍️ fonts and palettes ------------------------------------------------------ 15 | 16 | font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") 17 | font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") 18 | 19 | txt <- "grey20" 20 | bg <- "white" 21 | accent <- txt 22 | 23 | sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") 24 | autumn <- c('#1c2426', '#455852', '#9d8e71', '#d4935d', '#cc612b', '#a5371e', '#ab443b') 25 | 26 | font_add_google("Raleway", "raleway", regular.wt = 200) 27 | font_add_google("Josefin Sans", "jose", regular.wt = 200, bold.wt = 700) 28 | ft <- "raleway" 29 | ft <- "jose" 30 | showtext_auto() 31 | 32 | # 🚙 functions --------------------------------------------------------------- 33 | 34 | 35 | 36 | # 🤼 wrangle ----------------------------------------------------------------- 37 | 38 | df <- vesuvius |> 39 | drop_na() 40 | 41 | # 🔡 text -------------------------------------------------------------------- 42 | 43 | caption <- make_caption(accent, bg) 44 | 45 | x <- c(0.1, 0.25, 0.5, 1) 46 | 47 | # 📊 plot -------------------------------------------------------------------- 48 | 49 | df |> 50 | ggplot(aes(log(depth_km), duration_magnitude_md)) + 51 | stat_density_2d(aes(fill = after_stat(level)), geom = "polygon", alpha = 0.5, linewidth = 0.25, colour = NA, n = 200) + 52 | scale_fill_gradientn(colours = pencil_case$spec$div) + 53 | scale_x_continuous(breaks = log(x), labels = glue("{x*1000}m"), ) + 54 | labs( 55 | title = "Seismic Events at\nMount Vesuvius", 56 | subtitle = "On average events are recorded at a depth of 240m (median)", 57 | x = "Depth", 58 | y = "Duration\nmagnitude", 59 | caption = caption 60 | ) + 61 | theme_void() + 62 | theme( 63 | text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), 64 | plot.background = element_rect(fill = bg, colour = bg), 65 | panel.background = element_rect(fill = "grey95", colour = NA), 66 | plot.title = element_text(size = 128, hjust = 0.5, margin = margin(b = 30), face = "bold"), 67 | plot.subtitle = element_text(hjust = 0.5, margin = margin(b = 20)), 68 | plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 55)), 69 | plot.margin = margin(b = 20, t = 75, r = 150, l = 75), 70 | axis.text = element_text(margin = margin(t = 10, r = 10)), 71 | axis.ticks = element_line(linewidth = 0.25), 72 | axis.ticks.length = unit(0.25, "cm"), 73 | axis.title.x = element_text(margin = margin(t = 10)), 74 | axis.title.y = element_text(margin = margin(r = 10), angle = 90), 75 | legend.position = "none" 76 | ) 77 | 78 | ggsave("scripts/2025/19 - mount vesuvius/mount vesuvius.png", height = 12, width = 12) 79 | -------------------------------------------------------------------------------- /scripts/2025/19 - mount vesuvius/mount vesuvius.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doehm/tidytues/786e72ba17421c173da4ccbc8ca1c85f0cddc5ae/scripts/2025/19 - mount vesuvius/mount vesuvius.png -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | img { 2 | max-height: 800px 3 | } 4 | -------------------------------------------------------------------------------- /tidytues.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 4e17ee29-c15c-4323-b061-519210748591 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: Sweave 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | --------------------------------------------------------------------------------