At Brian Ripley's request, I started putting together a minimal package to
illustrate the problem (see below for my original post).  As usually
happens, I have stumbled on the problem: our zzz.R file contained the
command:

.noGenerics <- TRUE

which we probably copied blindly from some example.  After removing this I
was able to use exportMethods(mean) instead of export(mean), as
recommended.  In case others find this helpful, I copy the following, which
I found in the help file for library {base}.

"
Formal methods

library takes some further actions when package methods is attached (as it
is by default). Packages may define formal generic functions as well as
re-defining functions in other packages (notably base) to be generic, and
this information is cached whenever such a package is loaded after
methodsand re-defined functions are excluded from the list of
conflicts. The check
requires looking for a pattern of objects; the pattern search may be avoided
by defining an object .noGenerics (with any value) in the package.
Naturally, if the package *does* have any such methods, this will prevent
them from being used.
"

Regards,

Jay

On Dec 8, 2007 4:12 PM, Jay Emerson <[EMAIL PROTECTED]> wrote:

> We are building a package, and want to create S4 methods for both head and
> mean for our own BigMatrix class.  Following the recommendation in "Writing
> R Extensions" we use exportMethods instead of export in NAMESPACE (this is
> described as being "clearer").  This works for head, but not for mean.
> Obviously we importFrom(utils, head), but don't need  to do this for mean,
> which is imported automatically from base.
>
> If we export(mean) rather than exportMethods(mean), it works as intended.
>
> A similar problem arises for a new generic function and an associated
> method, colmean, where the use of exportMethods(colmean) fails, but
> export(colmean) succeeds.
>
> We can build and use the package by using export instead of exportMethods,
> but we suspect that we're missing something that might be important to
> understand.
>
> Any hints or links to something we missed would be appreciated.
>
> Thanks,
>
> Jay Emerson
> Michael Kane
>
>
> --
> John W. Emerson (Jay)
> Assistant Professor of Statistics
> Director of Graduate Studies
> Department of Statistics
> Yale University
> http://www.stat.yale.edu/~jay
>



-- 
John W. Emerson (Jay)
Assistant Professor of Statistics
Director of Graduate Studies
Department of Statistics
Yale University
http://www.stat.yale.edu/~jay

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to