Skip to content
Prev 317371 / 398506 Next

Inserting rows of interpolated data

Hi Jon,

zoo is great for tasks like this, not just for na.approx. :)

I would approach the problem like this:

library(zoo)
# put lightdata into a zoo object
z <- with(lightdata, zoo(light,
  as.POSIXct(paste(date, time), format="%m/%d/%y %H:%M:%S")))
# merge the above zoo object with an "empty" zoo
# object that has all the index values you want
Z <- merge(z, zoo(,seq(start(z),end(z),by="1 min")))
# interpolate between the 5-min observatoins
Z <- na.approx(Z)

HTH,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.com
On Mon, Feb 11, 2013 at 5:19 PM, Benstead, Jonathan <jbenstead at as.ua.edu> wrote: