我正在关注那本很棒的Forecasting: Principles and Practice书。但即使我复制代码有时我的代码会出错并且不起作用。我有fpp2,ggplot2库。
beer2 <- window(ausbeer, start=1992)
fit.beer <- tslm(beer2 ~ trend + season)
autoplot(beer2, series="Data") +
forecast::autolayer(fitted(fit.beer), series="Fitted") +
xlab("Year") + ylab("Megalitres") +
ggtitle("Quarterly Beer Production")
错误:输入无效:date_trans仅适用于类Date的对象
如何解决此错误?代码可以在http://otexts.org/fpp2/Regr-UsefulPredictors.html
中找到R版本3.4.2(2017-09-28) 平台:x86_64-w64-mingw32 / x64(64位) 运行于:Windows&gt; = 8 x64(build 9200)
Matrix产品:默认
区域设置: 1 LC_COLLATE = English_United States.1252 LC_CTYPE = English_United States.1252 LC_MONETARY = English_United States.1252 [4] LC_NUMERIC = C LC_TIME = English_United States.1252
附加基础包: 1 stats graphics grDevices utils数据集方法库
其他附件包:
1 scales_0.5.0 GGally_1.3.2 bindrcpp_0.2 readxl_1.0.0 quantmod_0.4-11 TTR_0.23-2 CADFtest_0.3-3
[8] urca_1.3-0 sandwich_2.4-0 dynlm_0.3-5 Quandl_2.8.0 tseries_0.10-42 ggfortify_0.4.1 fpp2_2.1
[15] ggplot2_2.2.1 expsmooth_2.3 fma_2.3 forecast_8.2 xts_0.10-0 zoo_1.8-0 xlsx_0.5.7
[22] xlsxjars_0.6.1 rJava_0.9-9
通过命名空间加载(而不是附加):
1 Rcpp_0.12.13 lattice_0.20-35 tidyr_0.7.2 prettyunits_1.0.2 digest_0.6.12 assertthat_0.2.0
[7] lmtest_0.9-35 R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 MatrixModels_0.4-1 httr_1.3.1
[13] progress_1.1.2 rlang_0.1.2 lazyeval_0.2.1 curl_3.0 minqa_1.2.4 SparseM_1.77
[19] car_2.1-5 fracdiff_1.4-2 nloptr_1.0.4 Matrix_1.2-11 labeling_0.3 splines_3.4.2
[25] lme4_1.1-14 stringr_1.2.0 munsell_0.4.3 compiler_3.4.2 pkgconfig_2.0.1 mgcv_1.8-20
[31] nnet_7.3-12 tidyselect_0.2.3 tibble_1.3.4 gridExtra_2.3 quadprog_1.5-5 reshape_0.8.7
[37] dplyr_0.7.4 MASS_7.3-47 grid_3.4.2 nlme_3.1-131 jsonlite_1.5 gtable_0.2.0
[43] magrittr_1.5 stringi_1.1.5 reshape2_1.4.2 timeDate_3012.100 RColorBrewer_1.1-2 tools_3.4.2
[49] glue_1.2.0 purrr_0.2.4 parallel_3.4.2 pbkrtest_0.4-7 colorspace_1.3-2 bindr_0.1
[55] quantreg_5.34