[R] Problem with a global variable

From: Thomas L Jones, PhD <jones3745_at_verizon.net>
Date: Tue, 4 Dec 2007 00:51:23 -0500

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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 04 Dec 2007 - 05:55:39 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 Tue 04 Dec 2007 - 12:30:16 GMT.

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