From ripley@stats.ox.ac.uk  Fri Oct 26 20:53:20 2001
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Fri, 26 Oct 2001 21:53:20 +0200 (MET DST)
Subject: [Rd] warnings --- wish/bug (PR#1148)
Message-ID: <200110261953.VAA03710@pubhealth.ku.dk>

On Fri, 26 Oct 2001, kjetil halvorsen wrote:

> An example with a local package:
>
> > library(nonpar)
> > chisq.gof( rnorm(80), distribution=pnorm)
>
>      Pearson Chi-square goodness of fit test
>
> data:  rnorm(80)
> Chi-square = 19.1397, degrees of freedom = 11,
> p-value = 0.05863
> alternative hypothesis: true is not equal to pnorm ()
>
> Warning message:
> Minimum expected value is  2.61552251298291  <=5. Chi-square
> approximation may be unsatisfactory in: chisq.gof(rnorm(80),
> distribution = pnorm)
> >
>
> (where on the Rgui console (windows 98) the lines after "Warning
> message"
> extend out of sight)

That's bad design, but you can scroll the RGui window, surely?

BTW, that's nothing to do with warnings().  The internal code assumes that
the author has used sensible line lengths in the call to warning (R or C)
or warningcall (C).

>
> Kjetil Halvorsen
>
> Prof Brian D Ripley wrote:
> >
> > This is difficult.  The internal warnings should work as often as
> > possible without doing memory allocation, which might provoke an error
> > (*and* we try to print out warnings after a memory allocation error).
> > So strwrap is a no-no internally.
> >
> > I've not seen warnings that are not wrapped by the console
> > (on Unix) or are scrollable (Rgui).   Can you give us an example of the
> > problem?
> >
> > Incidentally, I think you want to strwrap the ... too.
> >
> > On Fri, 26 Oct 2001 kjetilh@umsanet.edu.bo wrote:
> >
> > > When R prints warnings, they often go "out of the line", it would be
> > > better if they where wrapped with
> > > writeLines(strwrap ...
> > >
> > > I tried to do that , changing the function warnings, but it has only
> > > effect when called explicitely, not when R prints the warnings unasked.
> > >
> > > Anyhow, here is the changed warnings:
> > >
> > > warnings <-
> > > function (...)
> > > {
> > >     if (!(n <- length(last.warning)))
> > >         return()
> > >     names <- names(last.warning)
> > >     cat("Warning message", if (n > 1)
> > >         "s", ":\n", sep = "")
> > >     for (i in 1:n) {
> > >         out <- if (n == 1)
> > >             names[i]
> > >         else paste(i, ": ", names[i], sep = "")
> > >         if (length(last.warning[[i]])) {
> > >             temp <- deparse(last.warning[[i]])
> > >             out <- paste(out, "in:", temp[1], if (length(temp) >
> > >                 1)
> > >                 " ...")
> > >         }
> > >         writeLines(strwrap(out), ...)
> > >     }
> > > }
> > >
> > >
> > > Kjetil Halvorsen
> > >
> > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> > > r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> > > Send "info", "help", or "[un]subscribe"
> > > (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> > > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > >
> >
> > --
> > Brian D. Ripley,                  ripley@stats.ox.ac.uk
> > Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> > University of Oxford,             Tel:  +44 1865 272861 (self)
> > 1 South Parks Road,                     +44 1865 272860 (secr)
> > Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] warnings --- wish/bug (PR#1148)
ripley@stats.ox.ac.uk