Skip to content

Commit 00f27f5

Browse files
authored
Create 2023w38_cran_authors.R
just the main file, no other files attached,
1 parent 3feb5a0 commit 00f27f5

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

2023w38_cran_authors.R

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
library(tidyverse)
2+
library(ggstream)
3+
library(ggrepel)
4+
library(ggtext)
5+
library(camcorder)
6+
7+
gg_record(dir = "tidytuesday-temp", device = "png", width = 10, height = 7, units = "in", dpi = 320)
8+
9+
10+
cran_20230905 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-19/cran_20230905.csv')
11+
12+
cran_ggplot <- cran_20230905 %>%
13+
mutate(year = year(as.Date(Date))) %>%
14+
reframe(
15+
package = Package,
16+
ggplot_d = str_detect(Depends, "ggplot"),
17+
ggplot_s = str_detect(Suggests, "ggplot"),
18+
year
19+
) %>%
20+
group_by(year) %>%
21+
summarise(
22+
ggs = sum(ggplot_s, na.rm = TRUE),
23+
ggd = sum(ggplot_d, na.rm = TRUE)
24+
) %>%
25+
ungroup() %>%
26+
filter(year <= 2023) %>%
27+
pivot_longer(ggs:ggd)
28+
29+
annot <- cran_ggplot %>%
30+
filter(year == max(year)) %>%
31+
mutate(y = c(-20, 120)) %>%
32+
mutate(label = case_when(
33+
name == "ggd" ~ paste0("**", value, "**<br>packages<br>currently"),
34+
name == "ggs" ~ paste0("**", value, "**<br>packages"),
35+
))
36+
37+
f1 <- "Bricolage Grotesque"
38+
39+
ggplot(cran_ggplot) +
40+
# ggplot2 release
41+
geom_label_repel(data = NULL, aes(x = 2007, y = 0, label = "ggplot2\nreleased"), family = f1, stat = "unique", direction = "y", nudge_y = 50, label.padding = 0.3, label.size = NA, fill = "#DED4E8", color = colorspace::darken("#DED4E8", 0.8), lineheight = 0.9) +
42+
geom_point(data = NULL, aes(x = 2007, y = 0), size = 3, stat = "unique", color = colorspace::darken("#DED4E8", 0.5)) +
43+
# Stream
44+
geom_stream(aes(x = year, y = value, fill = name, color = after_scale(colorspace::darken(fill))), size = 0.1) +
45+
geom_richtext(data = annot, aes(x = year + 0.2, y = y, label = label), family = f1, hjust = 0, lineheight = 0.9, label.size = 0, fill = "#DED4E8") +
46+
scale_x_continuous(breaks = seq(2007, 2023, 5), minor_breaks = 2007:2023) +
47+
scale_fill_manual(values = c("#C7395F", "#E8BA40")) +
48+
coord_cartesian(clip = "off") +
49+
labs(
50+
title = "Number of packages <span style='color:#C7395F'>depending on</span> or <span style='color:#E8BA40'>suggesting</span> ggplot2",
51+
subtitle = "Aggregated by year of each package's latest CRAN release as of 5 September 2023",
52+
caption = "Source: CRAN collaboration graph · Graphic: Georgios Karamanis"
53+
) +
54+
theme_minimal(base_family = f1) +
55+
theme(
56+
legend.position = "none",
57+
plot.background = element_rect(fill = "#DED4E8", color = NA),
58+
panel.grid.major.y = element_blank(),
59+
panel.grid.minor.y = element_blank(),
60+
panel.grid.major.x = element_line(color = colorspace::darken("#DED4E8", 0.1)),
61+
panel.grid.minor.x = element_line(color = colorspace::darken("#DED4E8", 0.1)),
62+
axis.title = element_blank(),
63+
axis.text.x = element_text(size = 12, margin = margin(10, 0, 0, 0)),
64+
axis.text.y = element_blank(),
65+
plot.margin = margin(10, 50, 10, 10),
66+
plot.title = element_markdown(face = "bold", size = 20),
67+
plot.subtitle = element_text(margin = margin(0, 0, 20, 0)),
68+
plot.caption = element_text(margin = margin(20, 0, 0, 0))
69+
)

0 commit comments

Comments
 (0)