[R] updating a helper function in a R package

From: Tao Shi <shitao_at_hotmail.com>
Date: Thu, 6 Dec 2007 22:38:36 +0000

Hi list,

Sorry for the vague title, but here is the scenario.

Im writing an R package, lets say, pkg1, which contains 3 functions: f1, f2, f3. f2 and f3 are helper functions for f1, i.e. f1 calls f2 which in turn calls f3.

f1 <- function() {



f2 <- function(){



f3 <- function(...){


Then, I wrote a new version of f3 and I want to test it. With the old version of pkg1 already loaded into my R session, I tried just copy-and-paste the new f3 to R console and hope f1 will pick the new f3 up. It obviously didnt work. I know its b/c the new f3 and old f3 are in different environments and when f1 is called, only old f3 is used. Then I tried to change the environment of new f3 to the same as the old f3's by calling:

environment(f3) <- environment(pkg1:::f3)

but it wasn't working either.


1)	Could somebody help me to put all these into perspectives?
2)	Is there an easier way to update f3 without rebuilding the package? (by that I mean, writing the new version of f3 in a way that I only need to copy-and-paste to R console and Im good to go.  I know its kind of stupid but Im curious to know) 

I'm using R-2.5.1, on WinXP.

Many thanks,



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. Received on Thu 06 Dec 2007 - 22:41:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 07 Dec 2007 - 00:30:18 GMT.

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