Re: [R] Overloading %*%

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Sun, 16 Mar 2008 19:47:29 -0700

Dear Martin:

      This is wonderful. Thank you very much.

      It would be a great help if your suggestions could be added to "See Also" and "Examples" for "methods".

      Thanks again,
      Spencer Graves

Martin Morgan wrote:
> Spencer Graves wrote:
>
>> Thanks, Ken.
>>
>> 1. How can I find S4 methods for a given function given class(es)
>> of objects? The 'showMethods' function lists available generics for a
>> given function; "showMethods('%*%')" just produced for me a list of 52
>> different signatures for "%*%". However, I don't know how to find the
>> functions with methods for a particular class. The 'methods' function
>>
>
> Use the 'classes' argument to showMethods, either with or without a
> function as first argument.
>
>
>> will produce either S3 methods for a given function or S3 functions for
>> a given class. It would help me if the 'methods' help page included
>> "See Also" and "Examples" for S4 classes also, but it doesn't.
>>
>> 2. How can I find source code for S4 methods? I tried
>>
>
> use includeDef=TRUE with showMethods, or getMethod to get a specific
> method, or, for some fun, selectMethod to find the method to which
> object dispatch occurs. I'm not sure how to dump the method to a file.
>
> Martin
>
>
>> "dumpMethods('%*%', 'mmult.R')" and got an apparently empty file of 0
>> KB. Then I tried 'dumpMethod("%*%", c(x="TsparseMatrix", y="ANY"))' and
>> got a file with the following:
>>
>> setMethod("%*%", structure(c("TsparseMatrix", "ANY"), .Names = c("x", "y")),
>> NULL
>> )
>>
>> Thanks again for your reply regarding "%*%".
>> Spencer Graves
>>
>> knoblauch wrote:
>>
>>> Joe Cainey <jcainey <at> gmail.com> writes:
>>>
>>>
>>>> Is it possible to supply a new method for the %*% operator?
>>>>
>>>>
>>> clipped
>>>
>>>
>>>> I've tried to do the same thing with %*%:
>>>>
>>>> "%*%.ad" <- function(a,b)
>>>> {
>>>> # further code here
>>>> }
>>>> However this doesn't work; the new method is never called and the standard
>>>> %*% operator is used instead. I've had a look at the documentation and it
>>>> appears to be because the %*% operator is not part of the "Math", "Ops",
>>>> "Summary" or "Complex" groups. I was wondering if anybody knew of a
>>>> work-around for this?
>>>>
>>>>
>>> According to the help page for %*%, it is S4 generic but not S3, so
>>> you might make further progress using S4 methods.
>>>
>>>
>>>
>>>> Thanks,
>>>>
>>>> Joe Cainey
>>>>
>>>>
>>>>
>>> best,
>>>
>>> Ken
>>>
>>> ______________________________________________
>>> R-help_at_r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 17 Mar 2008 - 02:52:55 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 Mon 17 Mar 2008 - 08:30:22 GMT.

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

list of date sections of archive