linear interpolate missing values in time series

前端 未结 4 977
悲哀的现实
悲哀的现实 2020-12-09 21:01

I would like to add all missing dates between min and max date in a data.frame and linear interpolate all missing values, like

df <- data.fra         


        
4条回答
  •  攒了一身酷
    2020-12-09 21:15

    I think your code would look much clear and simple if you use Forecast package.

    library(forecast)
    x <- zoo(df$value,df$date)
    x <- as.ts(x)
    x <- na.interp(x)
    print(x)
    

提交回复
热议问题