Steffen,
Linear interpolation is available through the function approx, or you could use
the function spline for cubic spline interpolation. Neither of these functions
accepts NAs, so you will need to preprocess. Assuming that your time stamps are
in a vector t0 and data in vector y0, consider something like:
t1 <- t0[!is.na(y0)] ##removes times at which data is not available
y1 <- y0[!is.na(y0)]
z <- approx(t1, y1, t0, method="linear") ##estimates values of y at all
original time stamps
## if you want just a fixed number of output points, say 50, on a uniform grid
between min(x) and max(x),
## use approx(t1, y1, n=50, method="linear")
## to extract the time and data vectors from list z, use t2 <- z$x and y2 <- z$y
Hope that is of use.
Nikhil
____________________________________________
N. S. Padhye, Ph.D.
Assistant Professor, Biostatistician
University of Texas Health Science Center at Houston
http://www.uth.tmc.edu
Dear List
I'm absolutely new in this field.
Can anybody help me, how I can fill the NAs of a time series with
plausible values with easy methods of s-plus?
I'm very glad about your answer.
Yours sincerely
Steffen
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|