The few times I want to patch a function like this, I use: unlockBinding(name, env); assignInNamespace(name, value, ns=pkgName, envir=env); assign(name, value, envir=env); lockBinding(name, env);
/Henrik On Sun, Aug 17, 2008 at 10:50 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > In that case add this: > > unlockBinding("strucplot", as.environment("package:vcd")) > assign("strucplot", my.strucplot, "package:vcd") > > > > On Sun, Aug 17, 2008 at 1:22 PM, Ben Bolker <[EMAIL PROTECTED]> wrote: >> Gabor Grothendieck <ggrothendieck <at> gmail.com> writes: >> >>> >>> Check out: >>> >>> ?assignInNamespace >>> >>> On Sun, Aug 17, 2008 at 12:42 PM, Michael Friendly wrote: >>> > I'm trying to test an extension of mosaic() from the vcd package that >>> > requires a change to the >>> > basic strucplot() function from that package. I want to test my change by >>> > sourcing the >>> > replacement function into my R session. >>> > >> >> Yes, but: >> >> from the note in ?assignInNamespace >> >> assignInNamespace and fixInNamespace change the copy in the namespace, >> but not any copies already exported from the namespace, in particular >> an object of that name in the package (if already attached) and any >> copies already imported into >> other namespaces. They are really intended to be used only >> for objects which are >> not exported from the namespace. They do attempt to alter >> a copy registered as >> an S3 method if one is found. >> >> So if strucplot is exported from the vcd namespace (which I guess >> it is), this won't work. >> >> When I ran into a similar situation recently I couldn't find any >> solution other than rebuilding the package with my changes. >> >> Ben Bolker >> >> ______________________________________________ >> R-help@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. >> > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.