From zhengda1936 at gmail.com  Thu Dec 24 20:52:47 2015
From: zhengda1936 at gmail.com (Da Zheng)
Date: Thu, 24 Dec 2015 14:52:47 -0500
Subject: [Rd] override pmin/pmax for my own matrix
In-Reply-To: <CAOQ5NyfkOaXGbXjNLXgBPm80k_NbzOrCFeF4sibPhwz3+j5sEA@mail.gmail.com>
References: <CAFLer83+2DvP9dvcB7nfTreKodLknoDdKOKTSaTyp6YmQSdtmA@mail.gmail.com>
	<CAOQ5NyfkOaXGbXjNLXgBPm80k_NbzOrCFeF4sibPhwz3+j5sEA@mail.gmail.com>
Message-ID: <CAFLer83ruLkqjFtaSbzNffHYeWaKjTdYXt9QDi+NPRDd8wNn7Q@mail.gmail.com>

Thank you. It works!

On Thu, Dec 24, 2015 at 9:08 AM, Michael Lawrence
<lawrence.michael at gene.com> wrote:
> Yes, functions like c, min and max are special cases, as they are
> primitives. For ordinary functions, you just need to promote them with
> "..." as the signature:
>
> setGeneric("pmax", signature="...")
> setMethod("pmax", "Class", function(..., na.rm=FALSE) { })
>
> One caveat is that all arguments passed via "..." must derive from the
> class specified for "..." in the method signature. At some point we
> should solve that by introducing a binary pmin2, pmax2 as we have for
> cbind and rbind.
>
>
> On Thu, Dec 24, 2015 at 5:54 AM, Da Zheng <zhengda1936 at gmail.com> wrote:
>> Hello,
>>
>> I'm trying to override pmin and pmax for my own matrix. These two
>> functions have ... as an argument. I tried to override them as
>> follows:
>>     setMethod("pmax", class_name, function(x, ..., na.rm) { ... })
>>
>> I use this way to override primitive functions such as min/max and it
>> works fine.
>> But it doesn't work for pmin and pmax. I guess because they are
>> regular functions?
>> How do I override a regular function with ... as an argument?
>>
>> Thanks,
>> Da
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] override pmin/pmax for my own matrix
Da Zheng