[R] Problem with a global variable

Thomas L Jones, PhD jones3745 at verizon.net
Tue Dec 4 06:51:23 CET 2007

From: Thomas Jones

I have several user-defined functions. As is standard practice, I am 
defining a logical vector named idebug in order to control debugging 
printouts. For example, if idebug [1] has the value TRUE, such-and-such 
debugging printouts are enabled. After the function works, some or all of 
the debugging printouts can be inhibited. idebug is a global variable; 
otherwise, it would have to be moved around with function arguments in a way 
which is clunky and hard to get right. However, I am getting an error 
message. This message was emitted during the loading of the program and is 
NOT inside any function.

Or perhaps idebug wants a special slot on the search path.


> debug_l <- 5 # length of debug vector
> idebug <<- logical (5)
> idebug [1] <<- TRUE
Error in idebug[1] <<- TRUE : object "idebug" not found

Your advice?

Tom Jones

More information about the R-help mailing list