Monday, February 04, 2008

R package: codetools

Since the release of R_2.6.0, R package developers were advised to use the ``codetools" package to check potential bugs. However, as I am not familiar with computer language, I found the warning messages a bit confusing. For example:

> checkUsage(glm.fit)
: no visible binding for global variable ‘n’

I don't understand what it really means. Apparently, `n' was not globally defined but was used inside the glm.fit(). Nonetheless, this is really not a bug.

I found checkUsage() and checkUsagePacakge() are useful in finding redundant code. For example:


bar <- function(x){   
  x.bar <- mean(x)   
  mu <- mean(x, na.rm=TRUE)   
  return(mu) 
} 

> checkUsage(bar)
: local variable ‘x.bar’ assigned but may not be use

No comments: