Skip to content

Instantly share code, notes, and snippets.

@bfatemi
Created March 23, 2016 17:45
Show Gist options
  • Save bfatemi/cba3d7a011825e857bfc to your computer and use it in GitHub Desktop.
Save bfatemi/cba3d7a011825e857bfc to your computer and use it in GitHub Desktop.
Example of accessing the function call stack
### Example of accessing the function call stack
IsHungry <- function(){
e <- substitute(cat(sub("\\(.*\\)", " ", deparse(sys.calls()[[i]]))))
Bob <- function(n){
Loves <- function(n){
Burgers <- function(n){
TheEnd <- function(n){
invisible(sapply(1:n, function(i) eval(e, list(i))))
}
TheEnd(sys.nframe())
}
Burgers(sys.nframe())
}
Loves(sys.nframe())
}
Bob(sys.nframe())
}
IsHungry()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment