This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #### 1. Sign up at GitHub.com ################################################ | |
| ## If you do not have a GitHub account, sign up here: | |
| ## https://github.com/join | |
| # ---------------------------------------------------------------------------- | |
| #### 2. Install git ########################################################## | |
| ## If you do not have git installed, please do so: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(dplyr) | |
| library(forcats) | |
| library(ggplot2) | |
| library(palmerpenguins) | |
| library(ggtext) | |
| library(colorspace) | |
| library(ragg) | |
| url <- "https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/man/figures/lter_penguins.png" | |
| img <- magick::image_read(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| gm_2023 <- readr::read_csv("https://www.cedricscherer.com/data/gapminder-2023.csv") | |
| pal <- c(Africa = "#00D9EE", Americas = "#4CF101", Asia = "#FF4670", Europe = "#FFE702", Oceania = "#CA4ADC") | |
| # base plot | |
| g <- | |
| ggplot(gm_2023, aes(x = gdp_pcap, y = life_exp, size = pop)) + | |
| geom_point( | |
| color = "white", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| library(treemapify) | |
| library(ggtext) | |
| library(prismatic) | |
| owid_urban <- readr::read_csv("https://www.ggplot2-uncharted.com/data/hyde.csv") | |
| treemap <- owid_urban |> | |
| sf::st_drop_geometry() |> | |
| filter(!is.na(continent)) |> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| library(patchwork) | |
| # get photo | |
| img <- magick::image_read("https://www.yan-holtz.com/img/team/YH_pic_square.png") | |
| # retrieve lightness | |
| c <- magick::image_channel(img) | |
| img_df <- tibble::as_tibble(as.data.frame.table(drop(as.integer(c[[1]])))) | |
| img_df <- dplyr::mutate(img_df, across(c(Var1, Var2), as.numeric)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| value <- 7.3 | |
| ggplot() + | |
| # Add gap to bottom | |
| coord_radial( | |
| start = 4/3 * pi, # 240° | |
| end = 2/3 * pi, # 120° | |
| expand = FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| df_students <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-05-07/student_teacher_ratio.csv") | |
| df_world_tile <- readr::read_csv("https://gist.githubusercontent.com/maartenzam/787498bbc07ae06b637447dbd430ea0a/raw/9a9dafafb44d8990f85243a9c7ca349acd3a0d07/worldtilegrid.csv") %>% | |
| mutate( | |
| ## Namibias two-digit country code is handled as `NA` - let us fix that | |
| alpha.2 = if_else(name == "Namibia", "NA", alpha.2), | |
| ## We are going to split "Americas" into "North America" and "Sout America" | |
| region = if_else(region == "Americas", sub.region, region), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(systemfonts) | |
| mpg_sum <- mpg %>% | |
| ## just use 2008 data | |
| dplyr::filter(year == 2008) %>% | |
| ## turn into lumped factors with capitalized names | |
| dplyr::mutate( | |
| manufacturer = stringr::str_to_title(manufacturer), | |
| manufacturer = forcats::fct_lump(manufacturer, n = 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## packages | |
| library(ggplot2) | |
| library(dplyr) | |
| library(tidyr) | |
| library(ggbraid) | |
| library(colorspace) | |
| library(owidR) | |
| # plus ggtext via namespace | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(sf) | |
| library(terra) | |
| library(stars) | |
| library(ggspatial) | |
| library(systemfonts) | |
| library(patchwork) | |
| register_variant( | |
| name = "Input Mono Light", |
NewerOlder