[Rd] bus error /segmentation fault from 'approx' (PR#7177)
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Aug 16 12:01:20 CEST 2004
j.van_den_hoff at 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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list