R ts with missing values

前端 未结 3 506
春和景丽
春和景丽 2020-12-10 07:21

I have a data frame I read from a csv file that has daily observations:

Date        Value 
2010-01-04  23.4
2010-01-05  12.7
2010-01-04  20.1
2010-01-07  18         


        
3条回答
  •  心在旅途
    2020-12-10 08:12

    You can use the imputeTS, zoo or forecast package, which all offer methods to fill the missing data. (the process of filling missing gaps is also called imputation)

    imputeTS

    na.interpolation(yourData)
    na.seadec(yourdata)
    na.kalman(yourdata)
    na.ma(yourdata)
    

    zoo

    na.approx(yourdata)
    na.locf(yourdata)
    na.StructTS(yourdata)
    

    forecast

    na.interp(yourdata)
    

    These are some functions from the packages you could use.

提交回复
热议问题