From ripley at stats.ox.ac.uk  Tue Jun  6 14:36:56 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 6 Jun 2006 13:36:56 +0100 (BST)
Subject: [Rd] Editing a package with a NAMESPACE in place
In-Reply-To: <C0AAED04.C8D7%sdavis2@mail.nih.gov>
References: <C0AAED04.C8D7%sdavis2@mail.nih.gov>
Message-ID: <Pine.LNX.4.64.0606061332550.20451@gannet.stats.ox.ac.uk>

On Tue, 6 Jun 2006, Sean Davis wrote:

> I would like to edit a function from a package that uses a NAMESPACE, but in
> place (after the package is loaded).  As a simple example, I would like to
> add a browser() call to a line in one of the functions for debugging
> purposes.  Since the function is in the package namespace, I can't do that
> directly by simply making a copy of the function and editing it--that copy
> doesn't get used.  I tried assigning into the package environment, but it is
> locked, it appears.  How do I go about doing this without changing the
> package source, then reinstalling and reloading?

See the section on debugging in `Writing R Extensions' (which has this 
exact example).  Most easily by trace(), but you can also use 
fixInNamespace().

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Editing a package with a NAMESPACE in place
Prof Brian Ripley