[S] -- stamping name of function on a graph (summary)

Hudson, Spencer (shudson@viropharma.com)
Tue, 7 Apr 1998 11:09:30 -0400

My original question was:

Suppose I have a function mygraph() that plots some data. I would like
to identify the plot with the date and time (easy, using stamp()), and
the name of the function that created the plot. My question is, how do I
capture the name of a function from within the function while it is
running? This way I can use stamp(get.func.name()). Please respond
directly to me.

Thanks to :

Bill Venables [wvenable@attunga.stats.adelaide.edu.au]
Alan Zaslavsky [zaslavsk@hcp.med.harvard.edu]
gary@sabot.com <mailto:gary@sabot.com>
Bill Dunlap [bill@statsci.com]
Chuck Taylor [chuck@statsci.com]
ripley@stats.ox.ac.uk <mailto:ripley@stats.ox.ac.uk>
Brian Dawkins [bdawkins@MCS.VUW.AC.NZ]
Patrick Burns [pburns@pburns.seanet.com]
Jerome Asselin [jasselin@mat.ulaval.ca]

Most offered suggestions about sys.call() and sys.parent(). The two I
found easiest are:

From: Alan Zaslavsky [zaslavsk@hcp.med.harvard.edu]

I think the function whoffle() below will do the job:
get.func.name_function() as.character(sys.call(sys.parent(1))[[1]])

> whoffle_function() get.func.name()
> whoffle()
> whuffle_whoffle
> whuffle()
From: Patrick Burns [pburns@pburns.seanet.com]

Here is a little example of how to do what I think you want.
> fjj.par
> fjj.sub
c(this.fun = deparse(sys.call()[[1]]),
parent.fun = deparse(sys.calls()[[ sys.parent()]][[1]]))

And here is the result:
> fjj.par()
this.fun parent.fun
"fjj.sub" "fjj.par"
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news