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(gganimate) | |
library(systemfonts) | |
df_mac_raw <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-12-22/big-mac.csv') | |
df_mac <- | |
df_mac_raw %>% | |
mutate(year = lubridate::year(date)) %>% | |
dplyr::select(date, year, iso_a3, currency_code, name, local_price, |
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(igraph) | |
library(ggraph) | |
df <- readRDS("data.Rds") | |
graph <- graph_from_data_frame(df) | |
sorting <- c(25, 24, 1, 2, 3, 4, 5, 6, 7, 8, 26, 27, c(9:23)) |
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
#' Download data to draw Berlin template map | |
#' @examples download_data_berlin() | |
download_data_berlin <- function() { | |
## SETUP --------------------------------------------------------------------- | |
## output dir for raw geo files | |
dir <- here::here("data-raw", "geo-raw") | |
if (!dir.exists(dir)) dir.create(dir, showWarnings = TRUE, recursive = TRUE) | |
## DISTRICTS ----------------------------------------------------------------- |
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
set.seed(2021) | |
data <- tibble( | |
group = factor(c(rep("Group 1", 100), rep("Group 2", 250), rep("Group 3", 25))), | |
value = c( | |
## Group 1 | |
seq(0, 20, length.out = 100), | |
## Group 2 | |
c(rep(0, 5), rnorm(30, 2, .1), rnorm(90, 5.4, .1), rnorm(90, 14.6, .1), rnorm(30, 18, .1), rep(20, 5)), | |
## Group 3 |
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) | |
## data | |
## via https://projects.oregonlive.com/weather/temps/ | |
df <- | |
readr::read_csv("https://projects.oregonlive.com/weather/pdx_temps.csv") %>% | |
mutate(yday = lubridate::yday(date), | |
year = lubridate::year(date), | |
decade = year %/% 10 * 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
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
#' Function to extract Jupiter colors as hex codes | |
#' | |
#' @param ... Character names of colors | |
#' | |
#' @examples | |
#' jupiter_colors() | |
#' jupiter_colors("petrol") | |
#' | |
#' @export | |
jupiter_colors <- function(...) { |
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
--- | |
title: "Gender Pay Gap: Dumbbell Plot (EU only)" | |
author: | |
- name: "Cédric Scherer" | |
url: www.cedricscherer.com | |
output: | |
distill::distill_article: | |
highlight: kate | |
code_folding: false | |
toc: true |
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) | |
## data: | |
## https://www.kaggle.com/datasets/sudalairajkumar/daily-temperature-of-major-cities?resource=download | |
temp <- read_csv(here::here("city_temperature.csv")) | |
## select a few interesting city around the world | |
temp_selected <- | |
temp %>% | |
#filter(str_detect(City, "New York|London|Helsinki|Shanghai|Rio|Jakarta|Cairo|Canberra|Delhi|Capetown|Hong Kong|Reykjavik")) %>% |
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)) |