Skip to content

Instantly share code, notes, and snippets.

@favstats
Last active August 29, 2022 07:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save favstats/f9a5aaea01d6c3378b1a2160d5c86bd6 to your computer and use it in GitHub Desktop.
Save favstats/f9a5aaea01d6c3378b1a2160d5c86bd6 to your computer and use it in GitHub Desktop.
library(tidyverse)
## this r code is taking from here: https://github.com/mkearney/pkguse
read_r_files <- function(...) {
dirs <- unlist(list(...))
r <- unlist(lapply(dirs, list.files,
pattern = "\\.(R|Rmd|Rmarkdown|rmd|r|Rhistory)$",
recursive = TRUE,
full.names = TRUE,
all.files = TRUE))
suppressWarnings( x <- unlist(lapply(r, tfse::readlines)))
x
}
## read in r files
rss <- read_r_files(c("C://Users//favoo//Dropbox", "C://Users//favoo//Documents//git_proj"))
## parse everything that comes before assignment arrow "<-"
df_names <- rss %>%
stringr::str_extract("\\w+(?=.*<-)") %>%
na.omit() %>%
table(df_name = .) %>%
as_tibble()
## look at most common occuring variable names
df_names %>%
arrange(-n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment