-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
432 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
scripts/2023/week-37-global-human-day/global-human-day-s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
scripts/2023/week-39-roy-kent-f-count/roy-kent-f-count-s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
scripts/2023/week-43-patient-risk-profiles/patient-risk-profiles-s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
scripts/2023/week-49-life-expectancy/life-expectancy-aus-s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
scripts/2023/week-50-christmas-movies/christmas-movies-s.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# https://github.com/rfordatascience/tidytuesday | ||
|
||
# | ||
|
||
library(tidyverse) | ||
library(showtext) | ||
library(patchwork) | ||
library(janitor) | ||
library(glue) | ||
library(ggtext) | ||
library(ggwordcloud) | ||
|
||
# 💾 load data --------------------------------------------------------------- | ||
|
||
df <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2024/2024-12-10/parfumo_data_clean.csv') |> | ||
clean_names() | ||
|
||
# ✍️ fonts and palettes ------------------------------------------------------ | ||
|
||
txt <- "grey20" | ||
sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") | ||
perfume <- c("#EDE3E1", "#F3D9D7", "#F8CFCF", "#FCD7D8", "#FDE1E1", "#FCEBE9") | ||
font_add_google("Poppins", "pop", regular.wt = 200) | ||
ft <- "pop" | ||
pal <- perfume | ||
bg <- pal[3] | ||
showtext_auto() | ||
|
||
# 🤼 wrangle ----------------------------------------------------------------- | ||
|
||
make_word_df <- function(df, x) { | ||
tibble( | ||
word = str_split(df[x], ", ") |> | ||
reduce(c), | ||
category = x | ||
) | ||
} | ||
|
||
clean_brands <- function(x) { | ||
|
||
id <- str_detect(x, "/") | ||
|
||
ifelse( | ||
id, | ||
str_extract(x, ".+/") |> | ||
str_remove_all("/") |> | ||
str_trim(), | ||
x | ||
) | ||
|
||
} | ||
|
||
categories <- c("main_accords", "top_notes", "middle_notes", "base_notes") | ||
|
||
df_top_n <- df |> | ||
filter(rating_count > 100) |> | ||
arrange(desc(rating_value)) |> | ||
slice_head(n = 50) | ||
|
||
df_word <- map_dfr(categories, ~make_word_df(df_top_n, .x)) |> | ||
filter(!is.na(word)) |> | ||
mutate( | ||
word = str_remove_all(word, '"'), | ||
word = str_remove_all(word, '\\n'), | ||
word = tolower(word) | ||
) |> | ||
count(category, word) |> | ||
mutate( | ||
word = str_to_sentence(word), | ||
category = factor(category, levels = rev(c("main_accords", "base_notes", "middle_notes", "top_notes"))) | ||
) |> | ||
arrange(category, desc(n)) |> | ||
group_by(category) |> | ||
slice_head(n = 50) | ||
|
||
# 🔡 text -------------------------------------------------------------------- | ||
|
||
|
||
# 📊 plot -------------------------------------------------------------------- | ||
|
||
df_word |> | ||
ggplot() + | ||
geom_text_wordcloud(aes(label = word, size = n), family = ft, shape = "triangle-forward") + | ||
scale_size_area(max_size = 60) + | ||
facet_wrap(~category, ncol = 1) + | ||
theme_void() + | ||
theme( | ||
text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), | ||
# plot.background = element_rect(fill = bg, colour = bg), | ||
plot.title = element_text(size = 128, hjust = 0.5), | ||
plot.subtitle = element_text(), | ||
plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), | ||
plot.margin = margin(b = 20, t = 50, r = 50, l = 50), | ||
strip.text = element_blank() | ||
) | ||
|
||
# save -------------------------------------------------------------------- | ||
|
||
ggsave("scripts/2024/week-50-perfume/perfume.png", height = 16, width = 12) | ||
|
||
# bar chart of brands ----------------------------------------------------- | ||
|
||
df |> | ||
count(brand) |> | ||
mutate( | ||
brand = clean_brands(brand), | ||
brand = fct_reorder(brand, n) | ||
) |> | ||
arrange(desc(n)) |> | ||
slice_head(n = 30) |> | ||
ggplot() + | ||
geom_col(aes(brand, n), fill = txt) + | ||
scale_y_continuous(position = "right") + | ||
coord_flip() + | ||
theme_void() + | ||
theme( | ||
text = element_text(family = ft, size = 48, lineheight = 0.3, colour = txt), | ||
# plot.background = element_rect(fill = bg, colour = bg), | ||
plot.title = element_text(size = 128, hjust = 0.5), | ||
plot.subtitle = element_text(), | ||
plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), | ||
plot.margin = margin(b = 20, t = 50, r = 50, l = 50), | ||
strip.text = element_blank(), | ||
axis.text.y = element_text(hjust = 1), | ||
axis.line.x = element_line(), | ||
axis.ticks = element_line(), | ||
axis.ticks.length.x = unit(0.25, "cm"), | ||
axis.text = element_text() | ||
) | ||
|
||
# save -------------------------------------------------------------------- | ||
|
||
ggsave("scripts/2024/week-50-perfume/brands.png", height = 12, width = 10) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# https://github.com/rfordatascience/tidytuesday | ||
|
||
library(tidyverse) | ||
library(showtext) | ||
library(patchwork) | ||
library(janitor) | ||
library(glue) | ||
library(ggtext) | ||
library(ggchicklet) | ||
|
||
# 💾 load data --------------------------------------------------------------- | ||
|
||
conf2023 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-14/conf2023.csv') | ||
conf2024 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-14/conf2024.csv') | ||
|
||
# ✍️ fonts and palettes ------------------------------------------------------ | ||
|
||
|
||
font_add("fa-brands", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-brands-400.ttf") | ||
font_add("fa-solid", regular = "../../Assets/Fonts/fontawesome/webfonts/fa-solid-900.ttf") | ||
|
||
txt <- "grey20" | ||
bg <- "white" | ||
sunset <- c("#355070", "#6d597a", "#b56576", "#e56b6f", "#eaac8b") | ||
font_add_google("Poppins", "pop", regular.wt = 200) | ||
ft <- "pop" | ||
showtext_auto() | ||
|
||
# 🚙 functions --------------------------------------------------------------- | ||
|
||
first_name <- function(x) { | ||
str_sub(x, 1, 1) | ||
} | ||
|
||
last_name <- function(x) { | ||
map_chr(x, ~{ | ||
str_split_1(.x, " ") |> | ||
tail(1) |> | ||
str_sub(1,1) | ||
}) | ||
} | ||
|
||
# 🤼 wrangle ----------------------------------------------------------------- | ||
|
||
df <- conf2023 |> | ||
mutate(year = 2023) |> | ||
bind_rows( | ||
conf2024 |> | ||
mutate(year = 2024) | ||
) |> | ||
select(year, speaker_name) |> | ||
mutate( | ||
`First name` = first_name(speaker_name), | ||
`Last name` = last_name(speaker_name) | ||
) |> | ||
select(-speaker_name) |> | ||
pivot_longer(-year, names_to = "name", values_to = "val") |> | ||
group_by(year, name, val) |> | ||
mutate(n = 1:n()) | ||
|
||
# 🔡 text -------------------------------------------------------------------- | ||
|
||
caption <- make_caption(txt) | ||
title <- "posit::conf()" | ||
subtitle <- str_wrap("Distribution of the first letter of the speaker's first and last name. | ||
2023 was the year of the J's and M's. 2024 was the year of the A's. There has yet | ||
to be a speaker with a name starting with a Q, X, or Y.", 110) | ||
|
||
# 📊 plot -------------------------------------------------------------------- | ||
|
||
expand_grid( | ||
year = c(2023, 2024), | ||
name = c("First name", "Last name"), | ||
val = LETTERS | ||
) |> | ||
left_join(df, join_by(year, name, val)) |> | ||
ggplot() + | ||
geom_tile(aes(val, n, fill = n), width = 0.9, height = 0.9) + | ||
scale_fill_gradientn(colours = sunset) + | ||
facet_grid(year ~ name) + | ||
labs( | ||
title = title, | ||
subtitle = subtitle, | ||
caption = caption | ||
) + | ||
theme_void() + | ||
theme( | ||
text = element_text(family = ft, size = 32, lineheight = 0.3, colour = txt), | ||
plot.background = element_rect(fill = bg, colour = NA), | ||
plot.title = element_text(size = 128, hjust = 0.5, face = "bold", margin = margin(b = 10)), | ||
plot.subtitle = element_text(hjust = 0, margin = margin(b = 20), size = 48), | ||
plot.caption = element_markdown(colour = txt, hjust = 0.5, margin = margin(t = 20)), | ||
plot.margin = margin(b = 20, t = 50, r = 50, l = 50), | ||
legend.position = "none", | ||
panel.spacing = unit(1, "cm"), | ||
axis.text.x = element_text(margin = margin(t = 5)), | ||
strip.text = element_text(size = 48) | ||
) | ||
|
||
ggsave("scripts/2025/02-posit-conf/posit-conf.png", height = 10, width = 12) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.