R-beta: An all.names function

Douglas Bates (bates@stat.wisc.edu)
Mon, 28 Apr 1997 08:11:31 -0500 (CDT)


Message-Id: <m0wLqDf-000hhBC@franz.stat.wisc.edu>
Date: Mon, 28 Apr 1997 08:11:31 -0500 (CDT)
From: Douglas Bates <bates@stat.wisc.edu>
To: R-help@stat.math.ethz.ch
Subject: R-beta: An all.names function

I could not find the all.names function in R so I created the
enclosed.  Comments, criticisms, or changes to a one-liner by creating
nested anonymous functions are welcome.  I'll try to work out a
corresponding all.vars function.

### $Id: allFns.R,v 1.2 1997/04/28 13:08:21 bates Exp $
### Some replacement functions that are missing in R

### Determine all the names (symbols) occuring in an object.
### This is probably grossly inefficient.
all.names <-
  function (x) 
{
  if (mode(x) == "symbol") 
    return(as.character(x))
  if (length(x) == 0) 
    return(NULL)
  if (is.recursive(x)) 
    return(unlist(lapply(as.list(x), all.names)))
  character(0)
}   

### Local variables:
### mode: R
### End:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=