Hi all,

 

Issue: I merged two zoo objects (a regular and an irregular). After the
merge I used the function 'na.approx' to have also values in the resolution
of the regular time series.

 

Problem: After approximation some rows at the beginning or at the end of the
zoo objects disappear due to the 'na.approx' algorithm. Now I just want to
have all the rows of the regular time series with the approximated values of
the irregular time series back. Because some rows disappear I wasn't able to
program a code which works properly for 'all' circumstances. I also tried to
work with the 'index' function. Didn't work out so far.

 

Thank you for your help.

 

Regards,

Alex

 

***********************************************************

funLm <- function(gauge, orange){

 

gauge <- zoo(gauge$Precipitation, order.by = gauge$Time)

 

tstart <- ISOdatetime(year=2009, month=5, day=1, hour = 0, min = 0, sec = 0,
tz = "UTC")

tend <- ISOdatetime(year=2009, month=5, day=31, hour = 23, min = 59, sec =
59, tz = "UTC")

orangeMai <- window(orange, start=tstart, end=tend) 

gaugeMai <- window(gauge, start=tstart, end=tend)

 

mergeGaugeOrange <- merge.zoo(gaugeMai, orangeMai)

 

smoothing <- na.approx(mergeGaugeOrange)

 

na.index <- which(is.na(mergeGaugeOrange$orangeMai))

na.index <- if(na.index[1] != 1){na.index-(na.index[1]-1)}

 

regularZoo <- smoothing[c(na.index)]

 

rain.lm <- lm(orangeMai ~ gaugeMai, data=regularZoo)

 

par(mfrow=c(2,2))

plot(rain.lm)

 

}

***********************************************************


	[[alternative HTML version deleted]]

