[ESS] r-related question: editing NAMESPACEd functions in packages

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Nov 7 19:51:07 CET 2011


Hi,

In addition to what Gavin suggests below, you could consider using
Hadley's devtools package:

https://github.com/hadley/devtools

It's meant to help make authoring packaging easier ... on thing it can
do is reload your package from its source tree w/ proper handling of
redefined functions in your dev-package namespace.

In particular, I guess you'd be interested in the `load_all` and
perhaps `install` functions (with brief outlines in that README on the
landing page)

HTH,
-steve

On Mon, Nov 7, 2011 at 6:44 AM, Gavin Simpson <ucfagls at ucl.ac.uk> wrote:
> On Mon, 2011-11-07 at 11:03 +0000, Stephen Eglen wrote:
>> My turn to ask a question ...  it is mostly r-related, but does have an ESS
>> twist.
>>
>> None of my own R packages have ever had a NAMESPACE file, so I could
>> load the package, then dynamically edit its functions and re-eval it in
>> ESS just with ess-eval-defun.
>>
>> R 2.14.0 now seems to require NAMESPACE files.  So, if I now want to
>> edit and re-eval a function f in my package p, do I have to reload my
>> package, rather than just do ess-eval-defun on the function f?  (I think
>> just doing ess-eval-defun on the source code for f will then create two
>> versions of my function, one in global environment, and one in p::f)
>>
>> Are there any tips for keeping the edit-run cycle short when editing
>> functions in NAMESPACE'd packages?
>
> See ?assignInNamespace
>
> If you have f in global environment that is an edited version of p:::f
> then
>
> assignInNamespace("f", f, "p")
>
> will effectively do
>
> p:::f <- f
>
> so that if you call p:::f you get the modified f not the one originally
> defined in the NAMESPACE of p. If you rm(f) from the global env then you
> can work as before but using the new f and not the one defined in the
> package as run-time.
>
> G
>
>>
>> Stephen
>>
>> ______________________________________________
>> ESS-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help
>>
>
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
>  Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
> ______________________________________________
> ESS-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/ess-help
>



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the ESS-help mailing list