Re: [Rd] S3 vs S4 for a simple package

2008-01-08 Thread Oleg Sklyar
> Would you like existing functions such as mean, range, sum, > colSums, dim, apply, length, and many more to operate on the array of > numbers? If so use an S3 class. The above is misleading as 'setClass("NewArray", [additional structures go in here], contains="array")' will give the NewArray a

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread Gabor Grothendieck
On Jan 7, 2008 2:34 PM, John Chambers <[EMAIL PROTECTED]> wrote: > One thing you cannot do in S3 is to have methods that depend on anything > but the first argument. Actually, you can. Here are two examples. > ### first example - Axis ### > ### note that it can be dispatched on x or at > Axis fu

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread Douglas Bates
On Jan 7, 2008 1:34 PM, John Chambers <[EMAIL PROTECTED]> wrote: > Prof Brian Ripley wrote: > > On Mon, 7 Jan 2008, Robin Hankin wrote: > > > > > >> I am writing a package and need to decide whether to use S3 or S4. > >> > >> I have a single class, "multipol"; this needs methods for "[" and "[<-" >

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread Tim Hesterberg
Would you like existing functions such as mean, range, sum, colSums, dim, apply, length, and many more to operate on the array of numbers? If so use an S3 class. If you would like to effectively disable such functions, to prevent them from working on the object unless you write a method that spec

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread Oleg Sklyar
In EBImage I have a very similar situation (well, with more methods). It would be impossible to use S3 in my case as my data structures are images and I need at least two dimensions (but in fact use 3), thus 2 variables to dispatch on in [, which are defined for multiple configurations like int

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread John Chambers
Prof Brian Ripley wrote: > On Mon, 7 Jan 2008, Robin Hankin wrote: > > >> I am writing a package and need to decide whether to use S3 or S4. >> >> I have a single class, "multipol"; this needs methods for "[" and "[<-" >> and I also need a print (or show) method and methods for arithmetic +- >>

Re: [Rd] S3 vs S4 for a simple package

2008-01-07 Thread Prof Brian Ripley
On Mon, 7 Jan 2008, Robin Hankin wrote: > I am writing a package and need to decide whether to use S3 or S4. > > I have a single class, "multipol"; this needs methods for "[" and "[<-" > and I also need a print (or show) method and methods for arithmetic +- > */^. > > In S4, an object of class "mu

[Rd] S3 vs S4 for a simple package

2008-01-07 Thread Robin Hankin
I am writing a package and need to decide whether to use S3 or S4. I have a single class, "multipol"; this needs methods for "[" and "[<-" and I also need a print (or show) method and methods for arithmetic +- */^. In S4, an object of class "multipol" has one slot that holds an array. Objects o