[R] Mapping function dependencies

Martin Maechler maechler at stat.math.ethz.ch
Wed Aug 13 17:25:06 CEST 2003


>>>>> "TL" == Thomas Lumley <tlumley at u.washington.edu>
>>>>>     on Wed, 13 Aug 2003 07:16:43 -0700 (PDT) writes:

    TL> On Wed, 13 Aug 2003, David Khabie-Zeitoune wrote:
    >> With regards to my question below, I've found a way to do it:
    >> 
    >> all.names(body(test))
    >> 
    TL> This also gives all the variable names, which you may not want.

    TL> This question came up a few months ago:
    TL> http://finzi.psych.upenn.edu/R/Rhelp02/archive/18497.html

If you are willing to (install and) use "R-devel",
Luke Tierney has written a package "codetools" which does
what you want, at least gives you the building blocks:

You need R-devel (which will become R 1.8 in October):

  > library(help=codetools)

		  Information on Package 'codetools'

  Description:

  Package: codetools
  Version: 0.0-0
  Author: Luke Tierney <luke at stat.uiowa.edu>
  Description: Code analysis tools for R
  Title: Code Analysis Tools for R
  Depends: R (>= 1.8)
  Maintainer: Luke Tierney <luke at stat.uiowa.edu>
  License: GPL
  Built: R 1.8.0; ; 2003-08-13 17:13:31

  Index:

  callCC                  Call With Current Continuation
  checkUsage              Check R Code for Possible Problems
  codetools               Low Level Code Analysis Tools for R
  findGlobals             Find Global Functions and Variables Used by a
			  Closure
  showTree                Print Lisp-Style Representation of R
			  Expression

  > library(codetools)

  > findGlobals(lm)

   [1] "<-"             "=="             ">"              "-"             
   [5] "!"              "!="             "("              "["             
   [9] "[[<-"           "{"              "$<-"            "*"             
  [13] "&&"             "as.character"   "as.name"        "attr"          
  [17] "c"              "class<-"        "eval"           "if"            
  [21] "is.empty.model" "is.matrix"      "is.null"        "lapply"        
  [25] "length"         "levels"         "list"           "lm.fit"        
  [29] "lm.wfit"        "match.call"     "model.matrix"   "model.offset"  
  [33] "model.response" "model.weights"  "NROW"           "numeric"       
  [37] "parent.frame"   "return"         "sapply"         "stop"          
  [41] "warning"       
  > 

----

If you are not an R "newbie"
the package __IN SOURCE FORM__ (i.e. not compiled for Windows!)
can be downloaded from
    http://www.stat.uiowa.edu/~luke/R/codetools/

(Again: You need R-devel, and need to be able to install
	packages from source!)

Regards,
Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><




More information about the R-help mailing list