[R] get the enclosing function name
Duncan Murdoch
murdoch at stats.uwo.ca
Sat Dec 12 01:24:43 CET 2009
On 11/12/2009 8:50 AM, Hao Cen wrote:
> Hi,
>
> Is there a way to get the enclosing function name within a function?
You confused me at first with "enclosing function", but I think you can
do what you want using something like
f <- function() {
print(sys.call()[[1]])
}
f()
Duncan Murdoch
>
> For example, I would like to have a function getEnclosingFunctionName().
> It works like below
>
> f = function(){
> print(getEnclosingFunctionName())
>
> }
>
>
> f() # will print "f"
>
>
> Thanks
>
> Jeff
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list