statquant statquant - 7 months ago 26
R Question

How can Iist only functions and those that come from a package

I use the

package to parallelize some stuff and I am tired of indicating 5 functions in
everytime I need to use it.

I know I can do
but this transfers a lot of data to the workers and slow me down (there can be big tables defined).

So the question is how can I list only functions in the

I did that:

getAllFunctions <- function(envir=.GlobalEnv){
allClasses <- sapply(grep(x=ls(envir), pattern='^%', value=TRUE, invert=TRUE), FUN=function(x){class(eval(parse(text=x)))})
fnNames <- names(allClasses)[allClasses == 'function']

But that's ugly (and gives everything) and I'm sure there is an idiomatic way


From the comments:

as.list(.GlobalEnv)[sapply(.GlobalEnv, is.function)]