From Mark.Bravington at csiro.au  Thu Sep  2 05:01:23 2010
From: Mark.Bravington at csiro.au (Mark.Bravington at csiro.au)
Date: Thu, 2 Sep 2010 13:01:23 +1000
Subject: [Rd] introspective capabilities
In-Reply-To: <8762ypmw62.fsf@cantab.net>
References: <87iq2ws25s.fsf@cantab.net> <4C7BD5BB.7050501@gmail.com>
	<8762ypmw62.fsf@cantab.net>
Message-ID: <62C82B39B8A85E4B95A18F7F7B852F87057C9E94C3@exvic-mbx03.nexus.csiro.au>

Hi Christophe

You could also look at the 'foodweb' function in package 'mvbutils'-- and specifically 'callers.of'. It should do just what you want, though you do have to tell it which environments to search through.

bye
Mark

-- 
Mark Bravington
CSIRO Mathematical & Information Sciences
Marine Laboratory
Castray Esplanade
Hobart 7001
TAS

ph (+61) 3 6232 5118
fax (+61) 3 6232 5012
mob (+61) 438 315 623

Christophe Rhodes wrote:
> Duncan Murdoch <murdoch.duncan at gmail.com> writes:
> 
>> On 27/08/2010 7:52 AM, Christophe Rhodes wrote:
>>> Hi,
>>> 
>>> Is there any way, from R code, to perform introspection as to where
>>> certain names acquired their values?
>> 
>> There's the "keep.source" option to source() and the optional
>> "srcfile" argument to parse() that tell R to keep this information.
>> If you haven't changed the default
>> getOption("keep.source") from TRUE, then source will default to
>> keeping it, and you can find the original location of a function
>> definition for function f by looking in attr(body(f), "srcref").  See
>> ?srcref for the format; there aren't a lot of user-level utility
>> functions for working with this.
> 
> Thanks.  This is enough for my immediate purposes: supporting
> single-keystroke (M-.) jumping to source locations of functions. 
> 
>> For packages, the relevant option is "keep.source.pkgs" at the time
>> the package is installed.
> 
> Thank you.
> 
> Is there anything like a cross-referencing database within R?  The
> functionality I'm looking for here is to be able to name a function,
> and come back with a list of functions (or srcrefs) where that name
> is used.  (I realise that this is not in general possible; just the
> lexically-apparent cases would be enough).    
> 
> Cheers,
> 
> Christophe
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] introspective capabilities
Mark.Bravington at csiro.au