[Rd] warnings --- wish/bug (PR#1148)

kjetilh@umsanet.edu.bo kjetilh@umsanet.edu.bo
Fri, 26 Oct 2001 21:48:27 +0200 (MET DST)


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)

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

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._