[R] How do I obtain the current active path of a function that's being called?

David Winsemius dwinsemius at comcast.net
Wed Jun 6 02:12:21 CEST 2012


On Jun 5, 2012, at 7:51 PM, Michael wrote:

> Thanks so much for your help!
>
> I'd like but however I couldn't provide the code since they are not in
> public domain...
>
> But lets imagine I inherited a big pile of R projects/codes from other
> people and there are lots of "source"s in the programs.
>
> And there are many definitions of function "A" in the directories.
>
> I wanted to put a breakpoint into the relavant function "A" that's
> currently in the workspace, i.e. the one I am using...
>
> To insert a breakpoint, I need to find its location in the file  
> system... I
> need to find where it is...
>
> Simply searching by the name in the file system gave lots of hits...

You could go through and label each of the `A` functions with a  
comment that designated the file from which they were loaded.

 > func <- function() x
 > comment(func) <- "test"
 > comment(func)
[1] "test"

-- 
David.

>
> Thank you!
>
> On Tue, Jun 5, 2012 at 4:35 PM, Andrew Miles  
> <rstuff.miles at gmail.com> wrote:
>
>> Can you provide an example of the code file that you use to call the
>> different functions?  Without that it might be hard for people to  
>> answer
>> your question.
>>
>> Offhand, I'd say that it is whatever version of function A was called
>> last.  If you are loading functions into the workspace, they are  
>> treated as
>> any other object, which is to say that you can only have one  
>> function of
>> the same name at a time.  Hence whenever you call a source file to  
>> load in
>> function A, the old function A gets overwritten.
>>
>> Andrew Miles
>>
>>
>> On Jun 5, 2012, at 4:58 PM, Michael wrote:
>>
>>> Hi all,
>>>
>>> How do I obtain the current active path of a function that's being
>> called?
>>>
>>> That's to say, I have several source files and they all contain
>> definition
>>> of function A.
>>>
>>> I would like to figure out which function A and from which file is  
>>> the
>> one
>>> that's being called and is currently active?
>>>
>>> Thanks a lot!
>>>
>>>      [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> 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<http://www.r-project.org/posting-guide.html 
>> >
>>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list