Thanks to David Parkhurst and Sundar Dorai-Raj for responding with
suggestions. Sundar's solution did exactly what I needed. I would have
never thought to search for approx()!
The original email is next, followed by Sundar's response. Thanks
again.
Win Lambert
> S-PLUS6 on Windows XP
>
> I found this question in 3 emails in the archive, but did not see an
> answer. I have looked in my S-PLUS books, but perhaps am looking in
> the wrong place for the wrong thing. I want to do a relatively simple
> linear interpolation across missing values in a vector, e.g. ...850
> 862
> 875 NA NA 927 946... weighted by another non-missing (and never
> missing!) variable. Is there a function for this? If not, I can
> trudge through and figure out an algorithm, but would rather not waste
> time if I can do it in a one-liner.
>
> Thanks much.
>
Try ?approx. You'll need to supply an `x' but here's an example to help:
set.seed(1)
n <- 100
y <- sort(rnorm(n))
x <- seq(n)
na <- sample(n, 3) # remove 3 points
guess <- approx(x[-na], y[-na], xout = x[na])$y cbind(true = y[na],
guess)
--sundar
|