【发布时间】:2017-11-02 19:43:32
【问题描述】:
library(fpp)
library(purrr)
library(tidyr)
data(austourists)
tr <- window(austourists,end=c(2007,12))
te <- window(austourists, start=c(2008,1))
我有 FPP 包中的澳大利亚游客数据。我想创建多个时间序列对象,这些对象根据不同的起始年份进行修剪。
df <- as.data.frame(1999:2005)
colnames(df) <- "yr_start"
df$yr_end <- 2008
我想重复上面看到的窗口函数,但使用df 中的给定输入。我试图使用map 和nest 创建一个时间序列对象并将其嵌套到位。
我的目标是一个结构为
的数据框 head(df)
yr_start yr_end ts.object
<num> <num> <list>
1992 2008 <S3 class: ts object>
1993 2008 <S3 class: ts object>
1994 2008 <S3 class: ts object>
1995 2008 <S3 class: ts object>
1996 2008 <S3 class: ts object>
1997 2008 <S3 class: ts object>
目标是稍后使用这些 ts 对象在这些 ts 对象上使用 map 函数运行指数平滑模型。
【问题讨论】:
标签: r dataframe tidyr tidyverse purrr