na.locf but don't do trailing NAs

后端 未结 1 898
不知归路
不知归路 2021-01-12 06:23

I have the following time series

> y<- xts(1:10, Sys.Date()+1:10)
> y[c(1,2,5,9,10)] <- NA
> y
           [,1]
2011-09-04   NA
2011-09-05   NA         


        
相关标签:
1条回答
  • 2021-01-12 07:01

    Use na.approx from the zoo package (which is automatically loaded by xts):

    na.approx(y, method = "constant", na.rm = FALSE)
    
    0 讨论(0)
提交回复
热议问题