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
How about
lsf.str()
which should list all functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With