On Wed, 21 May 2003, Heywood, Giles wrote:
> I have a class defined as an extension to matrix:
> fooCLASS <- setClass("foo",representation("matrix"))
>
> and define a method for a generic function (no problem):
> setMethod("diff",signature(x="foo"),diff.foo <-
function(x){x})
>
> but I get a different behaviour for another generic function:
> setMethod("lag",signature(x="foo"),lag.foo <-
function(x){x})
>
> Error in assign(".packageName", pkg, env) :
> can't add bindings to a locked environment
>
> I did not get this behaviour under 1.5.1, it ran fine - any pointers?
lag() is in package ts, which has a namespace these days. Why are you
setting S4 methods on S3 generics? You will be able to set S3 methods.
> lag
function (x, ...)
UseMethod("lag")
<environment: namespace:ts>> diff
function (x, ...)
UseMethod("diff")
<environment: namespace:base>
(and BTW the base namespace is somewhat different and not locked).
The combination of S4 methods and namespaces is not supported, so if you
need this you will need to define the S4 generic somewhere you own.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595