5 min read

Identifying R Functions & Packages Used in GitHub Repos (funspotr part 1)

Tags: dplyr funspotr yaml purrr fs readr here

TLDR: funspotr provides helpers for spotting the functions and packages in R and Rmarkdown files and associated github repositories. See Examples for catalogues of the functions/packages used in posts by Julia Silge, David Robinson, and others. See follow-up posts for examples with github gists and how to pass parsed code collections into a network plot:

Documenting rstats posts

I was inspired by a few tweets I saw documenting the methods used in posts by popular #rstats communicators/developers:

As a complement to these resources, I thought it’d be helpful to see precisely which functions and packages were used in each post. See Julia Silge Blog and David Robinson Tidy Tuesday for tables containing the unique functions and associated packages used in each of their posts. I also created tables for functions in the R for Data Science Chapters and Bryan Shalloway Blog.

These Examples were made using the funspotr package that provides helpers for identifying R functions & packages in self-contained R files and associated github repositories. See funspotr website for documentation on how to apply funspotr to #rstats file(s) or repos1 as well as to see how the package works and current limitations. Message me if you use funspotr or feel free to open an issue if you’d be interested in adding additional funspotr-examples that I can link to!

Examples

The files in the github repos below were parsed and saved in funspotr-examples2 – specifically using R/save-examples.R to parse each file and record each instance of a function’s use to data/funs3.

Below, I only return the first use of a function in each post4 – except for R for Data Science Chapters where I only show the first use of a function across the entire book5.

library(dplyr)
library(readr)
library(DT)

Julia Silge Blog

Also posted table to google drive here.

The following package dependencies were not installed locally during parsing. Any function from these packages (along with any custom functions) will most likely be assigned pkgs = "(unknown)":
Lingua; EN; silgelib; packagesurvey; drlib; sqlstackr; tvthemes; parttree

readr::read_csv("https://raw.githubusercontent.com/brshallo/funspotr-examples/main/data/funs/jsilge-blog-funs-20220114.csv") %>% 
  distinct() %>% 
  DT::datatable(rownames = FALSE,
              class = 'cell-border stripe',
              filter = 'top',
              escape = FALSE,
              options = list(pageLength = 10))

David Robinson Tidy Tuesday

Also posted table to google drive here.

The following package dependencies were not installed locally during parsing. Any function from these packages (along with any custom functions) will most likely be assigned pkgs = "(unknown)":
ggflags; ebbr; rKenyaCensus; tidymetrics; shinymetrics; drlib; shinybones; treesnip; StatsBombR

readr::read_csv("https://raw.githubusercontent.com/brshallo/funspotr-examples/main/data/funs/drob-tidy-tuesdays-funs-20220114.csv") %>% 
  distinct() %>% 
  DT::datatable(rownames = FALSE,
              class = 'cell-border stripe',
              filter = 'top',
              escape = FALSE,
              options = list(pageLength = 10))