Skip to content
Prev 278090 / 398506 Next

Interpolating hourly basis

You didn't dput() your data as I asked so I can't work with it, but,
to get you started, here's an example of how you could do
interpolation of the sort you seem interested in using xts objects.
(It also seems like you need to decide what to make of the repeated
measurements before trying to extrapolate: do you want to average them
and use those values to interpolate or do something to take advantage
of repeated measurements?)

library(xts)
X <- xts( sin( (0:50)/2), Sys.Date()+7*(0:50))

X.interp <- xts( rep(NA, 351), Sys.Date()+0:350)
X.interp[time(X)] <- X

plot(X)
points(na.locf(X.interp), col = 3)
points(na.spline(X.interp), col = 2)

I don't think you need to change the second column of your data frame
to a date object: that information is encapsulated in the timestamps
you constructed. I'd use the constructor as
dat.xts=xts(dat[,-2],order.by=base_time)

I hope this helps,

Michael
On Sun, Nov 20, 2011 at 7:35 AM, abcdef ghijk <linehunk at yahoo.com> wrote:
Message-ID: <CAAmySGOUNTUCYCx67K+Ygpa1DbwTp9feX55mzsQv=ByZku8+4Q@mail.gmail.com>
In-Reply-To: <1321792522.74640.YahooMailNeo@web125406.mail.ne1.yahoo.com>