Use na.approx: set.seed(21) x <- xts(rnorm(10), Sys.time()-10:1) is.na(x) <- 2:4 is.na(x) <- 8:9 na.approx(x) na.spline(x)
Best, -- Joshua Ulrich | FOSS Trading: www.fosstrading.com On Tue, Jan 11, 2011 at 12:08 AM, Rustamali Manesiya <rmanes...@gmail.com> wrote: > Hello, > > I have a xts object, I would like to fill the NA with linear > interpolated data. Can anyone please help. > >> str(zz) > An ‘xts’ object from 2010-11-24 15:59:29 to 2010-11-24 16:00:00 containing: > Data: num [1:23401, 1] 312 312 312 312 312 ... > Indexed by objects of class: [POSIXct,POSIXt] TZ: > xts Attributes: > List of 2 > $ src : chr "datafeed" > $ updated: POSIXct[1:1], format: "2011-01-08 00:33:05" > >>zz > 2010-11-24 15:59:29 315.0300 > 2010-11-24 15:59:30 NA > 2010-11-24 15:59:31 NA > 2010-11-24 15:59:32 NA > 2010-11-24 15:59:33 NA > 2010-11-24 16:00:00 314.7000 > > > Rusty > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.