Tidy Tuesday R packages

Author
Affiliation
Published

December 26, 2023

tuesdata <- tidytuesdayR::tt_load('2023-12-26')
--- Compiling #TidyTuesday Information for 2023-12-26 ----
--- There are 3 files available ---
--- Starting Download ---

    Downloading file 1 of 3: `cran_20221122.csv`
    Downloading file 2 of 3: `external_calls.csv`
    Downloading file 3 of 3: `internal_calls.csv`
--- Download complete ---
## OR
tuesdata <- tidytuesdayR::tt_load(2023, week = 52)
--- Compiling #TidyTuesday Information for 2023-12-26 ----
--- There are 3 files available ---
--- Starting Download ---

    Downloading file 1 of 3: `cran_20221122.csv`
    Downloading file 2 of 3: `external_calls.csv`
    Downloading file 3 of 3: `internal_calls.csv`
--- Download complete ---
cran_20221122 <- tuesdata$cran_20221122
external_calls <- tuesdata$external_calls
internal_calls <- tuesdata$internal_calls
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tidygraph)

Attaching package: 'tidygraph'

The following object is masked from 'package:stats':

    filter
library(forcats)

What are the top packages by centrality?

I’m actually really surprised that the top ranking package by centrality is {duckdb}. It’s really become very ubiquitous.

cran_20221122 |> dplyr::filter(centrality_dir_mn_no0 > 2000) |> 
  mutate(package=fct_reorder(package, centrality_dir_md_no0)) |> 
  slice_max(centrality_dir_md_no0, n=20) |> 
  ggplot() + aes(x=package, y=centrality_dir_md_no0) +
  geom_col() + theme(axis.text = element_text(angle = 0)) + coord_flip()

cran_20221122 |> #dplyr::filter(centrality_dir_mn_no0 > 2000) |> 
  mutate(package=fct_reorder(package, node_degree_max)) |> 
  slice_max(node_degree_max, n=20) |> 
  ggplot() + aes(x=package, y=node_degree_max) +
  geom_col() + theme(axis.text = element_text(angle = 0)) + coord_flip()

Centrality Measures

my_graph <- cran_20221122 |>
  ggplot() +
  aes(x= centrality_dir_md_no0, y=centrality_dir_md, package=package) +
  geom_point()

plotly::ggplotly(my_graph)

The undirected versus directed measures are less correlated, indicating there are some packages that have high undirected centrality but not high directed centrality.

my_graph <- cran_20221122 |>
  ggplot() +
  aes(x= centrality_undir_md_no0, y=centrality_dir_md_no0, package=package) +
  geom_point()

plotly::ggplotly(my_graph)

Documentation versus Centrality

my_graph <- cran_20221122 |>
  dplyr::filter(centrality_dir_md_no0 < 1000) |>
  dplyr::filter(docchars_per_par_exp_md < 1000) |>
  ggplot() +
  aes(x=docchars_per_par_exp_md, y=centrality_dir_mn_no0, package=package) +
  geom_point()

plotly::ggplotly(my_graph)

Citation

BibTeX citation:
@online{laderas2023,
  author = {Laderas, Ted},
  title = {Tidy {Tuesday} {R} Packages},
  date = {2023-12-26},
  url = {https://laderast.github.io/posts/r-packages.html},
  langid = {en}
}
For attribution, please cite this work as:
Laderas, Ted. 2023. “Tidy Tuesday R Packages.” December 26, 2023. https://laderast.github.io/posts/r-packages.html.