How to list all the functions signatures in an R file?
r
Solution
UPDATE: Please refer to the answer by @Konrad Rudolph instead
You can create a new environment, source your file in that environment and then list the functions in it using lsf.str() e.g.
test.env <- new.env()
sys.source("myfile.R", envir = test.env)
lsf.str(envir=test.env)
rm(test.env)
or if you want to wrap it as a function:
listFunctions <- function(filename) {
temp.env <- new.env()
sys.source(filename, envir = temp.env)
functions <- lsf.str(envir=temp.env)
rm(temp.env)
return(functions)
}
Problem
Is there an R function that lists all the functions in an R script file along with their arguments? i.e. an output of the form: ``` func1(var1, var2) func2(var4, var10) . . . func10(varA, varB) ```