Re: [R-pkg-devel] Creating Accessor Methods

2016-03-10 Thread Kasper Daniel Hansen
Creating functions that looks like they have the same name, but have different internals is exactly (one of) the purposes of having methods. Best, Kasper On Thu, Mar 10, 2016 at 4:04 PM, Glenn Schultz wrote: > Hello Joris, > > Thank worked perfectly. My main concern was that I was creating mul

Re: [R-pkg-devel] Creating Accessor Methods

2016-03-10 Thread Glenn Schultz
Hello Joris, Thank worked perfectly. My main concern was that I was creating multiple methods which may have the same name but different signature. Just over thinking things I guess but I appreciate your time answering my question. Glenn > On Mar 10, 2016, at 8:13 AM, Joris Meys wrote: > >

Re: [R-pkg-devel] Creating Accessor Methods

2016-03-10 Thread Thomas Petzoldt
On 10.03.2016 16:48, Daniel Nüst wrote: Hi Glenn! On 10/03/16 15:05, Glenn Schultz wrote: I have a package with to S4 classes (MBSCashFlow, REMICCashFlow and BondCashFlow) all of which contain the slot Duration. I would like have an accessor Duration that would work on multiple signatures. Is

Re: [R-pkg-devel] Creating Accessor Methods

2016-03-10 Thread Daniel Nüst
Hi Glenn! On 10/03/16 15:05, Glenn Schultz wrote: I have a package with to S4 classes (MBSCashFlow, REMICCashFlow and BondCashFlow) all of which contain the slot Duration. I would like have an accessor Duration that would work on multiple signatures. Is this possible? I have checked my boo

Re: [R-pkg-devel] Creating Accessor Methods

2016-03-10 Thread Joris Meys
Hi Glenn, that is actually as easy as defining a generic and defining a method for each class to extract the slot. I do this literally in every package I write. setGeneric('duration', function(x, ...) standardGeneric('duration') setMethod('duration', signature = 'MBSCashFlow', function(x) { x@Du