> t1 <- c(1,3,5) > x1 <- c(2,1,Inf) > tt <- c(0,2,4,6) > approx( t1, x1, tt, method='constant', f=0 ) $x [1] 0 2 4 6 $y [1] NA 2 NaN NA The 3rd value, at tt=4, should be 1 from t1=3, x1=1, not NaN. The 4th value, at tt=6, should be Inf from t1=5, x1=Inf, not NA.

Your suggested output might be more desirable than the current output, but it isn't a bug, it is behaving as documented. The value is documented to be output as y0*(1-f)+y1*f, where y0 is the value to the left and y1 is the value to the right. For tt=4, we have y0 = 1 and y1 = Inf, and the output should be 1*1 + Inf*0. This is NaN. For tt=6, we have y0 = Inf and y1 = NA, so the result is NA. (You are asking for extrapolation here; you'd get NA even if the values were finite.) An argument could be made to special-case f=0 and f=1 to return y0 and y1 respectively. If nobody argues against that, I'll look into it.

Fixed in R-devel and R-patched.