>>>>> "Greg" == gregory r warnes <[EMAIL PROTECTED]> >>>>> on Thu, 2 Oct 2003 08:46:09 +0200 (MET DST) writes:
Greg> This message is in MIME format. Since your mail reader does not understand Greg> this format, some or all of this message may not be legible. Greg> ------_=_NextPart_000_01C388B0.D441A780 Greg> Content-Type: text/plain; charset="iso-8859-1" [ please *never* attach anything for bug reports. The current bug-management system messes up the MIME ] Greg> In debugging a long-running function where I Greg> occasionally call warnings() to write out any warnings Greg> that have occurred, I discovered that calling Greg> warnings() before any warnings have ever been Greg> generated causes an error: >> warnings() Greg> Error in warnings() : Object "last.warning" not found Greg> The problem is that warnings() attemts to check the Greg> length of the variable 'last.warning' without first Greg> checking for its existance. Greg> This problem exists in R 1.7.1 as well as in the new 1.8.0 beta code. Greg> A simple patch fixes the problem: Greg> --- warnings.R.orig 2003-10-02 02:35:04.359451000 -0400 Greg> +++ warnings.R 2003-10-02 02:42:08.900717000 -0400 Greg> @@ -1,6 +1,6 @@ Greg> warnings <- function(...) Greg> { Greg> - if(!(n <- length(last.warning))) Greg> + if(!exists("last.warning") || !(n <- length(last.warning))) Greg> return() Greg> names <- names(last.warning) Greg> cat("Warning message", if(n > 1)"s", ":\n", sep="") Thank you Greg! Fortunately, this falls into the category of "trivial bug fix" (it cannot break anything), and hence still goes into 1.8.0 Martin Maechler <[EMAIL PROTECTED]> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel