This is not at all comprehensive, and very hacky, but might be OK if you just need to find functions which are called within the script using parentheses. With your script saved in
random_script <- read_file("script.R")
strings_matching_open_paren_pattern <- random_script %>%
str_extract_all("[:graph:]*\\(", simplify = FALSE) %>% # e.g. 'c(', 'data.frame('
matched_functions <- strings_matching_open_paren_pattern %>%
- All functions are called with open parentheses, so for example this won't pick up the
- No spaces between function name and open parenthesis (e.g. per tidyverse style guide)
- All function names match the
[:graph:]* regex and everything matching that regex is a function name
The result might end up containing some junk and, depending on how big your script is, you might want to finesse the
matched_functions list a bit. Let me know if this helps!