Extract only stable functions from a tidyverse package

tidyverse
now
lifecycle
Author
Affiliations

Layal Christine Lettry

cynkra GmbH

University of Fribourg, Dept. of Informatics, ASAM Group

Published

October 12, 2023

Exploring the now package to write code without any obsolete functions

The now package

Thanks to Antoine Fabri’s post, I discovered the package now which allows to remove deprecated, superseded, defunct, questioning or reexported functions from tidyverse packages.

The README.md file is explains how we can see how many functions remain after having removed all the deprecated, superseded, defunct, questioning or reexported ones. See this table which comes from the README.md .

library(tidyverse)

before <- sapply(tidyverse_packages(), \(pkg) length(getNamespaceExports(pkg)))

now::clean_up_tidyverse(
  c(
    "experimental", "superseded", "deprecated", "defunct", "questioning",
    "reexports"
  )
)

after <- sapply(tidyverse_packages(), \(pkg) length(getNamespaceExports(pkg)))

left_join(enframe(before, value = "before"), enframe(after, value = "after"),
  by = "name"
) |>
  filter(after != before) |>
  mutate(keep_ratio = sprintf("%2.0f%%", 100 * after / before)) |>
  arrange(keep_ratio) |>
  knitr::kable()
name before after keep_ratio
tidyr 70 30 43%
purrr 189 91 48%
tibble 46 22 48%
dplyr 293 148 51%
rvest 40 23 58%
ragg 10 6 60%
pillar 45 28 62%
broom 9 6 67%
readxl 13 9 69%
rlang 440 340 77%
jsonlite 28 23 82%
hms 12 10 83%
googledrive 87 76 87%
googlesheets4 53 47 89%
haven 28 26 93%
readr 115 107 93%
dbplyr 162 153 94%
forcats 39 37 95%
stringr 59 56 95%
ggplot2 536 512 96%
lubridate 205 198 97%
modelr 34 33 97%

References

I assign the copyright for the content of the code above to Antoine Fabri.

Citation

BibTeX citation:
@online{lettry2023,
  author = {Lettry, Layal Christine},
  title = {Extract Only Stable Functions from a Tidyverse Package},
  date = {2023-10-12},
  url = {https://rdiscovery.netlify.app/posts/2023-10-12_now/},
  langid = {en}
}
For attribution, please cite this work as:
Lettry, Layal Christine. 2023. “Extract Only Stable Functions from a Tidyverse Package.” October 12, 2023. https://rdiscovery.netlify.app/posts/2023-10-12_now/.