[R] how to override/replace a function in a package namespace?

Michael Friendly friendly at yorku.ca
Sun Aug 17 18:42:38 CEST 2008


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.

But when I do that,
source("c:/R/mosaics/strucplot-MF.R")
and run my extension, it is apparent that it is vcd:::strucplot that is 
eventually called, not
my replacement.  Thus, I'm looking for something with the semantics and 
effect of
source("c:/R/mosaics/strucplot-MF.R", namespace="vcd")
that would replace the package version with my testing one.

This question may have come up before, but searching the usual sources 
hasn't turned up anything
useful.

-Michael

-- 
Michael Friendly     Email: friendly AT yorku DOT ca 
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list