Re: [Rd] Overriding S4 methods in an installed package

From: Allen McIntosh <mcintosh_at_research.telcordia.com>
Date: Sat, 18 Aug 2007 15:53:07 -0400

Seth Falcon wrote:
> Allen McIntosh <mcintosh@research.telcordia.com> writes:

>> Is it possible to override S4 methods in an installed package?
>> The naive
>> library("pkg")
>> setMethod("foo", signature(obj = "bar"),
>>         function(obj , x, y) { new definition }
>> 	, where="package:pkg")
>> results in the error
>> Error in setMethod("foo", signature(obj = "bar"), function(obj,  :
>>         the environment "pkg" is locked; cannot assign methods for function "foo"

>
> If foo is a generic that you are calling directly, then you can
> probably define it in the global environment (omit the where arg) and
> test it that way.
>
> OTOH, if foo is used by pkg internally, then it will be much easier to
> simply edit the source for pkg, reinstall and test. If you find and
> fix a bug, most package maintainers will be quite happy to integrate
> your fix.

Thanks for the suggestion. Unfortunately, foo() uses internal functions. When foo() is defined in the global environment, these are not visible.

I was hoping to avoid recompiling and installing under Windows. Looks like I may not have a choice.



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 18 Aug 2007 - 21:20:41 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 Sat 18 Aug 2007 - 22:38:50 GMT.

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