How to detect free variable names in R functions -


this question has answer here:

suppose have function:

f <- function() {   x + 1 } 

here x free variable since value not defined within function f. there way can obtain variable name, x, defined function, f?

i asking question while maintaining others' old r codes. there lot of free variables used, , makes debugging hard.

any suggestions welcomed well.

the codetools package has functions purpose, eg findglobals

findglobals(f, merge=false)[['variables']] # [1] "x" 

if redefine function have named argument x no variables returned.

f2 <- function(x){   x+1 } findglobals(f2, merge=false)[['variables']] # character(0) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -