Here's one really crude approach to get the package associated with each function. Yes, it will return a lot of stats and base records, but at least it is in a form you can filter.
It also won't tell you which version of the function you are using (although perhaps that could be inferred from the order of namespace results from getAnywhere, but at least tells you what the potential sources for the function are. You may be able to play with the output from getAnywhere some more to figure out which is in use.
code <- readLines("some_file_path.R")
# Recreate what I put in my file. This is the result of readLines.
code <- c("filter(this that or the other)",
"cut(some vector)",
"setNames(add the names in here)",
"file.exists(filename)",
"file_test(x, y, z)",
"ifelse(cut(x, y, z), yes, no)")
library(stringr)
fns <- str_extract_all(code, "[A-Z,a-z][A-Z,a-z,0-9,.,_]+\\(")
fns <- unlist(fns)
fns <- str_replace(fns, "\\(", "")
fns
process_getAnywhere <- function(ga){
where <- ga$where[grepl("package", ga$where)]
where <- sub("package[:]", "", where)
where
}
do.call("rbind",
lapply(fns,
function(f){
ga <- process_getAnywhere(getAnywhere(f))
data.frame(fn = rep(f, length(ga)),
pkg = ga,
stringsAsFactors = FALSE)
}
))