Skip to content
Prev 315421 / 398506 Next

Codetools Query (repost)

You really don't want to use internals like isBaseVar as there is no
guarantee they will continue to exist.  Even collectUsage and otehr
things mentioned on the same page may need to change if this is
reimplemented.

The most robust approach is to use findGlobals and omit what you don't
want, e.g.

     > omit <- ls("package:base", all.names=TRUE)
     > setdiff(findGlobals(moo),omit)
     [1] "y"

If you do want to use chollectUsage you could use something like

     funs <- new.env()
     omit <- ls("package:base", all.names=TRUE)
     enter <- function(type, v, e, w){
 	if (! v %in% omit)
 	    assign(v, TRUE, funs)
     }
     collectUsage(moo, enterGlobal = enter)

If %in% is too slow create a hashed envorinment and use exists().

Best,

luke
On Tue, 15 Jan 2013, Saptarshi Guha wrote: