Finds global functions and variables used by a closure.

findGlobals(fun, merge = TRUE)

Arguments

fun

function object; usually a closure.

merge

logical

Value

Character vector if merge is true; otherwise, a list with functions and variables character vector components. Character vectors are of length zero For non-closures.

Details

The result is an approximation. R semantics only allow variables that might be local to be identified (and event that assumes no use of assign and rm).

Author

Luke Tierney

Examples

findGlobals(findGlobals)
#>  [1] "<-"           "=="           "assign"       "c"            "collectUsage"
#>  [6] "if"           "list"         "ls"           "mkHash"       "sort"        
#> [11] "unique"       "{"           
findGlobals(findGlobals, merge = FALSE)
#> $functions
#>  [1] "<-"           "=="           "assign"       "c"            "collectUsage"
#>  [6] "if"           "list"         "ls"           "mkHash"       "sort"        
#> [11] "unique"       "{"           
#> 
#> $variables
#> character(0)
#>