powered by
Determines whether the current function call was initiated by a specified function. This is useful for conditional behavior depending on the caller.
calledBy(fun = "exams2pdf")called_by(fun = "exams2pdf")
called_by(fun = "exams2pdf")
A logical value: TRUE if the current call was triggered by fun, otherwise FALSE.
TRUE
fun
FALSE
Character string specifying the name of the calling function to check for. Defaults to "exams2pdf".
"exams2pdf"
funB <- function() { calledBy("funA") } funA <- function() { funB() } funA() # Returns TRUE because funB was called by funA
Run the code above in your browser using DataLab