r - Fill blank cells using linear interpolation -


first have excel not tool of trade, , people not r users. supposed easy task, struggling find way fill empty cells using linear interpolation. suppose have following excel sheet:

row date      interpolated date 1   09/09/13     2        3   15/10/13     4        5        6        7        8        9        10  03/04/14 

now copy non-empty values date interpolated date , fill empty cells interpolating between adjacent non-empty cells. note gap between empty values in date column haphazard. result should (this done using na.approx function zoo package r):

row date      interpolated date 1   09/09/13  09/09/13 2   <na>      27/09/13 3   15/10/13  15/10/13 4   <na>      08/11/13 5   <na>      02/12/13 6   <na>      26/12/13 7   <na>      20/01/14 8   <na>      13/02/14 9   <na>      09/03/14 10  03/04/14  03/04/14 

as far have understood, not possible using standard excel functions , 1 should maybe use vba macros. complete newbie in vba macros. found a similar question , solution it, not manage apply solution excel sheet. interpolated date column update either automatically, when values changed in date column or @ least simple button, user press update values. simplest way interpolation in case?

ps. here r code, if help:

dat <- structure(list(row = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), date = structure(c(15957, na, 15993, na, na, na, na, na, na, 16163), class = "date")), .names = c("row", "date"), row.names = c(na, -10l), class = "data.frame")  library(zoo) dat$interpolated.date <- as.date(na.approx(dat$date)) 

if have 2 dates in column separated intervening blanks, select cells (including 2 filled cells) , run tiny vba macro:

sub dateinterp()     selection.dataseries rowcol:=xlcolumns, type:=xlgrowth, date:=xlday, _         trend:=true end sub 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -