interpolating missing values from a TS
Aleks Clark wrote:
I've got a large TS with occasional NAs I'd like to roughly
interpolate, I'm currently doing this but it's pretty slow:
lapply(1:nrow(delta), function(i) {
lapply(1:ncol(delta), function(j) {
if (is.na(delta[i,j])) {
if ((i==1)||is.na(delta[i-1,j])) {
delta[i,j] <- delta[i+1,j]
} else { delta[i,j] <- delta[i-1,j]}
}
})
})
any ideas for a better solution
?na.approx