From r.hankin at noc.soton.ac.uk  Tue Apr 17 09:39:43 2007
From: r.hankin at noc.soton.ac.uk (Robin Hankin)
Date: Tue, 17 Apr 2007 08:39:43 +0100
Subject: [Rd] no visible binding for global variable
Message-ID: <3B7634A3-D77F-44A9-B9A4-4F51C0644721@soc.soton.ac.uk>

Hello everyone

I am trying to get one of my packages through R's QC.

The package is clean for me under  R-2.4.1, R-2.5.0, and
R-devel,  but Kurt gets


>
> * checking R code for possible problems ... WARNING
>  hypercube: no visible binding for global variable ?f?



Function hypercube() [cut-&-pasted below] is intended to
return an adjacency matrix for an n-dimensional
hypercube with 2^n nodes.  hypercube(n) returns a
2^n -by- 2^n matrix, and works as intended for me.

Can someone explain what the error message means?






"hypercube" <- function(n){

   jj <- as.matrix(expand.grid(rep(list(0:1),n)))

   wrapper <- function(x, y, my.fun) {
     f <- function(x,y,tol=1e-4){
       abs(sum(abs(jj[x,]-jj[y,]))-1)<tol
     }
     sapply(seq(along = x), FUN = function(i){f(x[i], y[i])})
   }

   o <- -outer(1:(2^n),1:(2^n), wrapper, my.fun=f)
   jj.names <- apply(jj,1,paste,collapse="")
   rownames(o) <- jj.names
   colnames(o) <- jj.names
   diag(o) <- -apply(o,1,sum,na.rm=TRUE)
   return(o)
}








--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



[Rd] no visible binding for global variable
Robin Hankin