我的预测数据如下,我想从此输出
创建一个数据框Fcast<-hw(pays, seasonal = "multiplicative",level=c(80,95), h = 12)
Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Jan 2018 82399311 81064000 83734623 80357129 84441494
Feb 2018 82240607 80906903 83574310 80200883 84280330
Mar 2018 87439677 86020230 88859124 85268820 89610534
Apr 2018 82121058 80786169 83455948 80079521 84162596
.. ... ...... ...... .... ..... .......
Nov 2018 84527743 83123530 85931956 82380184 86675302
Dec 2018 83393393 82000730 84786056 81263498 85523287
我想创建一个数据框,如下所示
Year Month Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
2018 Jan 82399311 81064000 83734623 80357129 84441494
2018 Feb 82240607 80906903 83574310 80200883 84280330
2018 Mar 87439677 86020230 88859124 85268820 89610534
答案 0 :(得分:0)
在dplyr中,以下内容对我有用。谢谢@Prem。
library(dplyr)
Fcast_df <- Fcast %>%
sweep::sw_sweep(.) %>%
filter(key == "forecast") %>%
select(-key)