Re: [Rd] no visible binding

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Fri, 12 Oct 2007 18:59:37 +0200 (CEST)

On Fri, 12 Oct 2007, roger koenker wrote:

> Could someone advise me about how to react to the message:
>
> * checking R code for possible problems ... NOTE
> slm: no visible binding for global variable 'response'
>
> from R CMD check SparseM with
> * using R version 2.6.0 Under development (unstable) (2007-09-03 r42749)
>
> The offending code looks like this:
>
> "slm" <-
> function (formula, data, weights, na.action, method = "csr",
> contrasts = NULL, ...)
> {
> call <- match.call()
> m <- match.call(expand.dots = FALSE)
> m$method <- m$model <- m$x <- m$y <- m$contrasts <- m$... <- NULL
> m[[1]] <- as.name("model.frame")
> m <- eval(m, sys.frame(sys.parent()))
> if (method == "model.frame")
> return(m)
> Terms <- attr(m, "terms")
> weights <- model.extract(m, weights)
> Y <- model.extract(m, response)

                             ^^^^^^^^

which becomes:

> as.character(substitute(response))

[1] "response"

inside model.extract. I'm not sure why codetools doesn't pick up weights in the same context one line earlier, probably because weights is also assigned to.

Hope this helps,

Roger

> X <- as.matrix.csr(model.matrix(Terms, m, contrasts))
> fit <- {
> if (length(weights))
> slm.wfit(X, Y, weights, method, ...)
> else slm.fit(X, Y, method, ...)
> }
> fit$terms <- Terms
> fit$call <- call
> attr(fit, "na.message") <- attr(m, "na.message")
> class(fit) <- c(if (is.matrix(Y)) "mslm", "slm")
> fit
> }
>
>
> url: www.econ.uiuc.edu/~roger Roger Koenker
> email rkoenker_at_uiuc.edu Department of Economics
> vox: 217-333-4558 University of Illinois
> fax: 217-244-6678 Champaign, IL 61820
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand_at_nhh.no

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 12 Oct 2007 - 17:02:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:37:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.