Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding all functions in current workspace

I'd like to find all functions in my current workspace and thought about using is.function for that purpose.

The "problem" is that is.function expects a true R object, not the character string name of an object.

That's my solution, but using eval(substitute(...)) seems a bit involved. Any ideas for a more straight forward way or is that the only way this can be done?

Example content

x <- TRUE
y <- 10
foo1 <- function() message("hello world!")
foo2 <- function() message("hello world again!")

Finding all function objects

wscontent <- ls(all.names=TRUE)
funs <- sapply(wscontent, function(ii) {
    eval(substitute(is.function(OBJ), list(OBJ=as.name(ii))))
})
> funs
     foo1      foo2      funs wscontent         x         y 
     TRUE      TRUE     FALSE     FALSE     FALSE     FALSE 
like image 877
Rappster Avatar asked Sep 17 '12 08:09

Rappster


1 Answers

How about

lsf.str()

which should list all functions.

like image 181
BenBarnes Avatar answered Sep 22 '22 15:09

BenBarnes