R-alpha: R bugs

Peter Parzer (Peter.Parzer@urz.uni-heidelberg.de)
Mon, 7 Oct 1996 12:09:15 +0200 (METDST)


Date: Mon, 7 Oct 1996 12:09:15 +0200 (METDST)
From: Peter Parzer <Peter.Parzer@urz.uni-heidelberg.de>
To: r-testers <r-testers@stat.math.ethz.ch>
Subject: R-alpha: R bugs
Message-Id: <Pine.A32.3.91.961007120759.10908B-100000@aixcomp1.urz.uni-heidelberg.de>

First I want to thank the authors of R for their great work and I want
to contribute as much as I can to the development of R.

I have just played a little bit with R and found 2 bugs. First, the
function rbinom(nobs,n,p) returns NA if p is 0 or 1. The following
diff removes this bug:

*** rbinom.c    Wed Oct  2 19:40:37 1996
--- rbinom.c.orig       Wed Oct  2 19:38:56 1996
***************
*** 43,55 ****
        /* setup, perform only when parameters change */
  
        n = floor(nin + 0.5);
!         if (n <= 0.0 || pp < 0.0 || pp > 1.0) {
                  errno = EDOM;
                  return -DBL_MAX;
          }
- 
-       if (pp == 0.0) return 0.0;
-       if (pp == 1.0) return nin;
  
        if (pp != psave) {
                psave = pp;
--- 43,52 ----
        /* setup, perform only when parameters change */
  
        n = floor(nin + 0.5);
!         if (n <= 0.0 || pp <= 0.0 || pp >= 1.0) {
                  errno = EDOM;
                  return -DBL_MAX;
          }
  
        if (pp != psave) {
                psave = pp;

Second, boxplot(x) does not work if x has some NA's. Again the diffs
to make boxplot() work:

*** boxplot     Wed Oct  2 20:03:30 1996
--- boxplot.orig        Wed Oct  2 19:45:13 1996
***************
*** 27,35 ****
  
  boxplot.stats := function(x, coef)
  {
!       x <- x[!is.na(x)]
!       n <- length(x)
!       stats <- fivenum(x)
        iqr <- diff(stats[c(2, 4)])
        out <- x < (stats[2]-coef*iqr) | x > (stats[4]+coef*iqr)
        if(coef > 0) stats[c(1, 5)] <- range(x[!out])
--- 27,34 ----
  
  boxplot.stats := function(x, coef)
  {
!       n <- length(!is.na(x))
!       stats <- fivenum(x, na.rm=TRUE)
        iqr <- diff(stats[c(2, 4)])
        out <- x < (stats[2]-coef*iqr) | x > (stats[4]+coef*iqr)
        if(coef > 0) stats[c(1, 5)] <- range(x[!out])


Peter Parzer
Peter.Parzer@urz.uni-heidelberg.de


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-