Is there a way for an R function to tell if it's being called from a `for` or `while` loop?

Viewed 476

The title of the question pretty much says it: is there a way for an R function to find out if it is being called directly or from inside a for or while loop? sys.frame(0) or parent.frame(1) returns .GlobalEnv whether the function was called directly or from inside one of those loops. So, is there some other way?

Thanks.

4 Answers
Related