Re: [R] function call

From: <vincent_at_7d4.com>
Date: Mon 19 Jun 2006 - 20:37:43 EST

Peter Dalgaard a écrit :

> vincent@7d4.com writes:
> 

>>Dear R-users,
>>
>>When a function f1() is called, is there a way to know,
>>from inside the function f1(), if f1() is directly called from the
>>R console, or indirectly from another function f2() ?
>>
>>Of course, I may add an argument to f1(..., callbyf2=FALSE) only used
>>by f2() giving explicitely this info, but I would like to know
>>if there may be a more generic way ?
>>
>>Thanks for any info or pointer
> 
> 
> You can always query via sys.status/sys.call/sys.function etc. Or, if
> the issue is whether the call is from the command line: 
> 
>   identical(parent.frame(), globalenv())
> 
> However, it does look a bit like unsound programming practice. Why do
> you perceive a need to do this?

I have some functions which may :
1/ either be called directly by the user thru the R console, to obtain only an information concerning a unique argument, f(arg1).
In this case, I sometimes like to get *detailed* information about the results : date(), file info, etc 2/ either be called from inside a for loop in a function f2() passing in review a long list of arguments, f(arg1),f(arg2),..., f(argn)
and summarizing the results
In this case, I don't want to see the details 100 times.

But my question was also simply for a better R knowledge.

interactive() seems nice.
Thanks for the info.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jun 19 20:40:51 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 19 Jun 2006 - 22:11:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.