Heywood, Giles
2004-Feb-26 18:10 UTC
[Rd] package 'stats' needs import directive for 1.9.0?
I maintain the Irregular Time Series (its) package on CRAN. I am currently testing a release. Under 1.8.1 I am able to define a S4 generic 'start' as follows: if(!isGeneric("start")) {setGeneric("start", useAsDefault=start)} Under 1.9.0, Rcmd check generates an error, as 'start' is not recognised. If I use the NAMESPACE directive IMPORT, all is well: import(stats) (I recall some past postings about refactoring 'base', and I assume that 'stats' is a part of this) However, the additional directive leads to problems under 1.8.1, as one might expect, since 'stats' does not exist under 1.8.1. How to define my S4 generic and make it transparent so that the base function start() is unaffected, in such a way that it will function under 1.8.1 and 1.9.0? Thanks - Giles ********************************************************************** This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
Prof Brian Ripley
2004-Feb-26 22:26 UTC
[Rd] package 'stats' needs import directive for 1.9.0?
I suggest you don't try: there are already quite a few 1.9.0-specific versions of packages on CRAN, and 1.8.x will be history in a couple of months. On Thu, 26 Feb 2004, Heywood, Giles wrote:> I maintain the Irregular Time Series (its) package on CRAN. I am currently > testing a release. Under 1.8.1 I am able to define a S4 generic 'start' as > follows: > > if(!isGeneric("start")) {setGeneric("start", useAsDefault=start)}Why do you need to do that? You could just define an S4 method which will automatically make a generic if needed.> Under 1.9.0, Rcmd check generates an error, as 'start' is not recognised. > If I use the NAMESPACE directive IMPORT, all is well: > > import(stats) > > (I recall some past postings about refactoring 'base', and I assume that > 'stats' is a part of this)See the NEWS file ....> However, the additional directive leads to problems under 1.8.1, as one > might expect, since 'stats' does not exist under 1.8.1. How to define my S4 > generic and make it transparent so that the base function start() is > unaffected, in such a way that it will function under 1.8.1 and 1.9.0?-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Swinton, Jonathan
2004-Feb-27 15:37 UTC
[Rd] package 'stats' needs import directive for 1.9.0?
> From: Prof Brian Ripley <ripley@stats.ox.ac.uk> > Subject: Re: [Rd] package 'stats' needs import directive for 1.9.0? > To: "Heywood, Giles" <Giles.Heywood@CommerzbankIB.com> > Cc: R-devel@stat.math.ethz.ch...> I suggest you don't try: there are already quite a few 1.9.0-specific > versions of packages on CRAN, and 1.8.x will be history in a > couple of > months. >I'm not sure I understand the advice here. I have also hit the same problem, and it seems reasonable to me to aspire to maintain a single package which works on both 1.8.x and 1.9.x.> On Thu, 26 Feb 2004, Heywood, Giles wrote: > > > I maintain the Irregular Time Series (its) package on CRAN. > I am currently > > testing a release. Under 1.8.1 I am able to define a S4 > generic 'start' as > > follows: > > > > if(!isGeneric("start")) {setGeneric("start", useAsDefault=start)} > > Why do you need to do that? You could just define an S4 > method which will > automatically make a generic if needed.I think that explicit Genericisation (?) has virtues from the point of view of code legibility. ...> > > However, the additional directive leads to problems under > 1.8.1, as one > > might expect, since 'stats' does not exist under 1.8.1. > How to define my S4 > > generic and make it transparent so that the base function start() is > > unaffected, in such a way that it will function under 1.8.1 > and 1.9.0? > >My solution was to only do a require(stats) if running > 1.9.