[R] codetools: checkUsage would not report the use of unbinded variables if they are binded later

Jannis bt_jannis at yahoo.de
Mon Apr 8 20:25:08 CEST 2013


Dear list members,




i try to use checkUsage from codetools to test my scripts and functions 
for errors. The scripts warn me correctly in case I use an unbinded 
variable but fail to do so in case I bind a value to it after its first 
usage in the script. Both cases, however, would result in the same r 
error. For example:



test = function() {
   b = 2*a
   return(b)
}

test2 = function() {
   b = 2*a
   a = 3
   return(b)
}


library(codetools)
checkUsage(test)
checkUsage(test2)


Is this a bug? Is there any way to get checkUsage to detect coding 
errors as in test2 ?


Thanks for your help

Jannis



More information about the R-help mailing list