【问题标题】:seasonal plot Error in data.frame(y = as.numeric(x)) arguments imply differing number of rows:data.frame(y = as.numeric(x)) 参数中的季节性图错误意味着不同的行数:
【发布时间】:2019-01-26 06:20:02
【问题描述】:

这是我的代码:

    month year GrandTotal   Date         
1     6  2014   15172331    2014-06-30
2     7  2014   24381383    2014-07-31
3     8  2014   24351338    2014-08-31
...
46     3  2018   85980914    2018-03-31
47     4  2018   72723488    2018-04-30


y <- ts(briskaranged, start=2014, frequency=12)
library(ggplot2)
#ploting of variables
autoplot(y) + 
labs(x ="Date", y = "GrandTotal", title = "Amount, ggplot2")
#seasonalplot
ggseasonplot(y, year.labels=TRUE, year.labels.left=TRUE) +
ylab("amount") +
ggtitle("Seasonal plot: amount transaction per day")

但编译器显示错误

data.frame 中的错误(y = as.numeric(x),year = trunc(time(x)),cycle = as.numeric(循环(x)),: 参数意味着不同的行数:235、47

【问题讨论】:

  • 最好逐行运行,找出第一次出现此错误的时间。从您的帖子中,尚不清楚何时会这样做。您还可以使用dput 提供briksaranged 的样本吗?也许运行traceback 电话?您能否将您的 ts 命名为其他名称而不是 y

标签: r ggplot2 time-series


【解决方案1】:
y <- ts(briskaranged$GrandTotal, start=2014, frequency=12)
library(ggplot2)
#ploting of variables
autoplot(y) + 
labs(x ="Date", y = "GrandTotal", title = "Amount, ggplot2")
#seasonalplot
ggseasonplot(y, year.labels=TRUE, year.labels.left=TRUE) +
ylab("amount") +
ggtitle("Seasonal plot: amount transaction per day")

【讨论】:

    猜你喜欢
    • 2014-11-26
    • 2014-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-03
    • 1970-01-01
    相关资源
    最近更新 更多