After an unsuccessful search thru several books plus online documentation, I 
was unable to find a simple way to do this, so I wrote my own function (see 
below) to do it.  I'm relatively new to R however, so I'm guessing that there 
must be an easier way to do it.

I want to list all functions and only the functions (not other objects also) in 
the global environment.

I'm working with several old R workspaces that contain a very large number of 
objects -- functions, data structures, etc. and I would to be able to easily 
find out which objects are functions.

The function below (listfunc()) works fine. I'm just asking this for future 
reference.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
listfunc <- function() { 
# lists names of all function objects in the global environment 
obj <- objects(.GlobalEnv) 
funclist <- character(length = 0) 
for (i in 1:length(obj)) { 
    if (mode(get(obj[i])) == "function") funclist <- c(funclist,obj[i]) 
  } 
return(funclist) 
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to