Re: [Rd] bus error /segmentation fault from 'approx' (PR#7177)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon 16 Aug 2004 - 20:01:20 EST

j.van_den_hoff@fz-rossendorf.de writes:

> follow up to ID 7166. something like
>
> approx(c(1,2),c(NA,NA),1.5,rule=2)
>
> crashes 1.9.1 on both systems (MacOS 10.3.5.: bus error, SunOS 5.9:
> segmentation fault) even if xout is within given x range (as in example above)
> where rule=2 seems not be relevant anyway.

Yes, this is a silly bug in the R driver routine:

    if (nx < 2 && method == "linear")

        stop("approx requires at least two values to interpolate")     if (any(na <- is.na(x) | is.na(y))) {

        ok <- !na
        x <- x[ok]
        y <- y[ok]
        nx <- length(x)

    }

You want to do the check after removing NAs!

Also, we should probably have a check for (nx == 0 && method != "linear")

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Mon Aug 16 20:40:06 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:07 EST