From hb at stat.berkeley.edu  Tue May 20 19:06:56 2008
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Tue, 20 May 2008 10:06:56 -0700
Subject: [Rd] S4 generic for lowess
In-Reply-To: <48328EB8.7050001@gmail.com>
References: <48328EB8.7050001@gmail.com>
Message-ID: <59d7961d0805201006m4c6b1dd0i9422ec31f8810c01@mail.gmail.com>

A quick comment on design:

On Tue, May 20, 2008 at 1:41 AM, Iago Mosqueira
<iago.mosqueira at gmail.com> wrote:
> Hi,
>
> A lowess method is defined in our package for one of our S4 classes. To
> explicitely define the generic this is being used
>
> if (!isGeneric("lowess"))
>  setGeneric("lowess", useAsDefault = lowess)
>
> This works fine for many other methods inherited from various R
> packages. In this case a warning is issued in R CMD check:
>
> * checking R code for possible problems ... NOTE
> lowess: no visible binding for global variable 'xy'
> lowess: no visible binding for global variable 'o'
>
> which I assume originates from the formals of lowess
>
> lowess(x, y = NULL, f = 2/3, iter = 3, delta = 0.01 * diff(range(xy$x[o])))
>
> where 'xy' and 'o' are present in the argument list but are really
> defined inside the function itself.

To my opinion, this could have been implemented as (or with some other
default value on 'delta'):

lowess <- function(x, y=NULL, f=2/3, iter=3, delta=NULL) {
  [...]
  if (is.null(delta))
    delta <- 0.01 * diff(range(xy$x[o])));
  [...]
}

and then document in the help pages what 'delta' defaults to.

My $.02

/Henrik

>
> I suppose I can safely ignore this warning, and the new methods seems to
> work fine, but I was curious to know if there is a better way to deal
> with this.
>
> Many thanks,
>
>
> Iago
>
> --
> Iago Mosqueira
> Cefas
> Systems Modelling
>
> Pakefield Rd.
> Lowestoft NR33 0HT
> U.K.
> +44 (0)1502 558003
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] S4 generic for lowess
Henrik Bengtsson