[R] Method dispatch
mtmorgan at fhcrc.org
Tue Mar 2 00:09:55 CET 2010
On 03/01/2010 01:31 PM, Zhang,Yanwei wrote:
> Dear all,
> In a package, I defined a method for "summary" using
setMethod(summary, signature="abc") for my class "abc", but when the
package is loaded, the function "summary(x)" where x is of class "abc"
seems to have called the default summary function for "ANY" class.
Shouldn't it call the method I have defined? How could I get around with
Hi Wayne -- It's hard to tell from what you've written, but this and
your earlier question on 'S4 issues' sounds like a NAMESPACE problem.
Are you using a name space? If so, provide additional detail. Also,
verify that you are only loading your package and not another, e.g., one
with a 'summary' generic that is being found before yours.
Probably your best bet is to simplify as much as possible -- I have a
single file in 'pkgA/R', with
setMethod("summary", "A", function(object, ...) "A")
R version 2.10.1 Patched (2010-02-23 r51168)
 LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
 LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
 LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
 LC_PAPER=en_US.UTF-8 LC_NAME=C
 LC_ADDRESS=C LC_TELEPHONE=C
 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
 stats graphics grDevices utils datasets methods base
other attached packages:
> Wayne (Yanwei) Zhang
> Statistical Research
> NOTICE: This e-mail message, including any attachments and appended messages, is for the sole use of the intended recipients and may contain confidential and legally privileged information.
> If you are not the intended recipient, any review, dissemination, distribution, copying, storage or other use of all or any portion of this message is strictly prohibited.
> If you received this message in error, please immediately notify the sender by reply e-mail and delete this message in its entirety.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the R-help