我正在尝试使用以下数据集来完成一个时间序列,预测未来两年按月收到的电话数量。
我使用了业务司机和车辆服务队列(英文+法文)
数据包括3列:呼叫的业务线、日期(月和年)和处理的电话数量。
对于我的初步分析,我尝试使用autoplot函数,但遇到了一些问题。我试过以下代码。
# Load the forecasting package
library(fpp3)
# Load the Data
load(Book3)
# Declare time series data
Book3 <- ts( Book3, [,3], start = 2016,1, frequency = 12)
############################################
Preliminary analysis
############################################
#Time Plot
autoplot(Book3) +
ggtitle("Test plot") +
ylab("Calls Handled")"Book3“是我的数据集的名称。然而,问题是,当我尝试运行它时,我会得到以下错误:
Error in `autoplot()`:
! Objects of type tbl_df/tbl/data.frame not supported by autoplot.
Run `rlang::last_error()` to see where the error occurred.还可以使用以下内容重构数据集:
structure(list(`Queue Group/Line of Business` = c("Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)",
"Driver and Vehicle Services queues (English + French)", "Driver and Vehicle Services queues (English + French)"
), DATE = c("2016-Jan", "2016-Feb", "2016-Mar", "2016-Apr", "2016-May",
"2016-Jun", "2016-Jul", "2016-Aug", "2016-Sep", "2016-Oct", "2016-Nov",
"2016-Dec", "2017-Jan", "2017-Feb", "2017-Mar", "2017-Apr", "2017-May",
"2017-Jun", "2017-Jul", "2017-Aug", "2017-Sep", "2017-Oct", "2017-Nov",
"2017-Dec", "2018-Jan", "2018-Feb", "2018-Mar", "2018-Apr", "2018-May",
"2018-Jun", "2018-Jul", "2018-Aug", "2018-Sep", "2018-Oct", "2018-Nov",
"2018-Dec", "2019-Jan", "2019-Feb", "2019-Mar", "2019-Apr", "2019-May",
"2019-Jun", "2019-Jul", "2019-Aug", "2019-Sep", "2019-Oct", "2019-Nov",
"2019-Dec", "2020-Jan", "2020-Feb", "2020-Mar", "2020-Apr", "2020-May",
"2020-Jun", "2020-Jul", "2020-Aug", "2020-Sep", "2020-Oct", "2020-Nov",
"2020-Dec", "2021-Jan", "2021-Feb", "2021-Mar", "2021-Apr", "2021-May",
"2021-Jun", "2021-Jul", "2021-Aug", "2021-Sep"), `Calls Handled` = c(70660,
61905, 63322, 68323, 72465, 67761, 64797, 77825, 71506, 71563,
73651, 62384, 78243, 66130, 72600, 57756, 71920, 75819, 73144,
82160, 70994, 73033, 66115, 53979, 71682, 57638, 66280, 56167,
75368, 70826, 73149, 79144, 70100, 72516, 63654, 53070, 73814,
57584, 66132, 63191, 72111, 63801, 68660, 67934, 57454, 56167,
49349, 45312, 60766, 50218, 56790, 62748, 84383, 95169, 79610,
70333, 80930, 75381, 77950, 78096, 73031, 60816, 89674, 74114,
74114, 74717, 64373, 64202, 99922)), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -69L))发布于 2022-11-22 00:34:15
用于将第3列转换为时间序列的语法不正确。它应该是:
Book3 <- ts(Book3[,3], frequency = 12, start = c(2016, 1))然后:
autoplot(Book3)

https://stackoverflow.com/questions/74526027
复制相似问题