Shows the relationship between calls on the stack. This function combines the results of sys.calls() and sys.parents() yielding a display that shows how frames on the call stack are related.

cst()

Examples

# If all evaluation is eager, you get a single tree f <- function() g() g <- function() h() h <- function() cst() f()
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. └─f() #> 26. └─g() #> 27. └─h() #> 28. └─lobstr::cst()
# You get multiple trees with delayed evaluation try(f())
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. ├─base::try(f()) #> 26. │ └─base::tryCatch(...) #> 27. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 28. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 29. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 30. └─f() #> 31. └─g() #> 32. └─h() #> 33. └─lobstr::cst()
# Pay attention to the first element of each subtree: each # evaluates the outermost call f <- function(x) g(x) g <- function(x) h(x) h <- function(x) x try(f(cst()))
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. ├─base::try(f(cst())) #> 26. │ └─base::tryCatch(...) #> 27. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 28. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 29. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 30. ├─f(cst()) #> 31. │ └─g(x) #> 32. │ └─h(x) #> 33. └─lobstr::cst()
# With a little ingenuity you can use it to see how NSE # functions work in base R with(mtcars, {cst(); invisible()})
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. ├─base::with(...) #> 26. └─base::with.default(...) #> 27. └─base::eval(substitute(expr), data, enclos = parent.frame()) #> 28. └─base::eval(substitute(expr), data, enclos = parent.frame()) #> 29. └─lobstr::cst()
invisible(subset(mtcars, {cst(); cyl == 0}))
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. ├─base::subset(...) #> 26. └─base::subset.data.frame(...) #> 27. └─base::eval(e, x, parent.frame()) #> 28. └─base::eval(e, x, parent.frame()) #> 29. └─lobstr::cst()
# You can also get unusual trees by evaluating in frames # higher up the call stack f <- function() g() g <- function() h() h <- function() eval(quote(cst()), parent.frame(2)) f()
#> █ #> 1. └─pkgdown::deploy_to_branch(new_process = FALSE) #> 2. └─pkgdown::build_site(...) #> 3. └─pkgdown:::build_site_local(...) #> 4. └─pkgdown::build_reference(...) #> 5. └─purrr::map(...) #> 6. └─pkgdown:::.f(.x[[i]], ...) #> 7. ├─base::withCallingHandlers(...) #> 8. └─pkgdown:::data_reference_topic(...) #> 9. └─pkgdown:::run_examples(...) #> 10. └─pkgdown:::highlight_examples(code, topic, env = env) #> 11. └─downlit::evaluate_and_highlight(...) #> 12. └─evaluate::evaluate(code, child_env(env), new_device = TRUE) #> 13. └─evaluate:::evaluate_call(...) #> 14. ├─evaluate:::timing_fn(...) #> 15. ├─evaluate:::handle(...) #> 16. │ └─base::try(f, silent = TRUE) #> 17. │ └─base::tryCatch(...) #> 18. │ └─base:::tryCatchList(expr, classes, parentenv, handlers) #> 19. │ └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 20. │ └─base:::doTryCatch(return(expr), name, parentenv, handler) #> 21. ├─base::withCallingHandlers(...) #> 22. ├─base::withVisible(eval(expr, envir, enclos)) #> 23. └─base::eval(expr, envir, enclos) #> 24. └─base::eval(expr, envir, enclos) #> 25. └─f() #> 26. ├─g() #> 27. │ └─h() #> 28. │ └─base::eval(quote(cst()), parent.frame(2)) #> 29. │ └─base::eval(quote(cst()), parent.frame(2)) #> 30. └─lobstr::cst()