Fer*_*ndo 12 interpolation r time-series zoo
我有一个缺少日期的气候时间序列(没有缺失值).例如:
n = 15
full.dates = seq(Sys.Date(), by = 'day', length = n)
serie.dates = full.dates[c(1:10, 12, 15)] # missing 11, 13, 14
y = rnorm(n)
require(zoo)
serie = zoo(y, serie.dates)
Run Code Online (Sandbox Code Playgroud)
在给出'full.dates'向量的情况下,我如何'填充'(使用插值)这些缺失点?谢谢!
Jos*_*ich 18
合并具有所需日期的"空"对象,然后使用na.approx(或na.spline等)填充缺失值.
x <- merge(serie, zoo(,seq(start(serie),end(serie),by="day")), all=TRUE)
x <- na.approx(x)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4690 次 |
| 最近记录: |