get_fun_calling_chain {envnames} | R Documentation |
Return the chain of calling functions
Description
Return a data frame with the stack or chain of function calls, or optionally the information on one particular function in this chain.
Usage
get_fun_calling_chain(n = NULL, showParameters = FALSE, silent = TRUE)
Arguments
n |
non-negative integer specifying the level of interest in the function calling chain,
where 0 means the function calling |
showParameters |
flag indicating whether the parameters of the function call should also be shown in the output. |
silent |
whether to run in silent mode. If FALSE, the calling chain is shown in an intuitive way.
It defaults to |
Value
If n=NULL
(the default) a data frame with the function calling chain information,
with the following columns:
fun
: the function name (including parameters ifshowParameters=TRUE
)env
: the function's enclosing enviroment, i.e. the environment where the function is defined as returned byenvironment(<function>)
envfun
: the environment where the function is defined together with the function name (and its parameters ifshowParameters=TRUE
) separated by a$
sign. Ex:env1$f()
The rownames of the data frame are the stack level of the function calls in the chain,
from 0 up to the number of functions in the chain, where 0 indicates the current function
(i.e. the function that called get_fun_calling_chain
).
The functions in the data frame are sorted from most recent to least recent call, much like the common way of displaying the function stack in debug mode.
If the function is NOT called from within a function, NULL
is returned.
If n
is not NULL and is non-negative, the environment and the function name (including parameters
if showParameters=TRUE
) separated by a $
sign are returned (ex: env1$f(x = 3, n = 1)
).
if n < 0
or if n
is larger than the function calling chain length, NULL
is returned.