r - 无法使用自动绘图可视化“ts” - 错误:提供连续比例的离散值
问题描述
我是新来的。我将列转换为ts
,但无法使用autoplot
library(tidyverse)
library(ggfortify)
library(forecast)
test <- ts(raw_mongolia_monthly$Time_Period, start = 2014, frequency = 12)
Jan Feb Mar Apr May Jun Jul Aug Sep
Oct Nov Dec
2014 2014/01 2014/02 2014/03 2014/04 2014/05 2014/06 2014/07 2014/08 2014/09
2014/10 2014/11 2014/12
2015 2015/01 2015/02 2015/03 2015/04 2015/05 2015/06 2015/07 2015/08 2015/09
2015/10 2015/11 2015/12
2016 2016/01 2016/02 2016/03 2016/04 2016/05 2016/06 2016/07 2016/08 2016/09
2016/10 2016/11 2016/12
2017 2017/01 2017/02 2017/03 2017/04 2017/05 2017/06
class(test)
[1] "ts"
autoplot(test)
**Error: Discrete value supplied to continuous scale**
我的数据
> dput(test)
structure(c("2014/01", "2014/02", "2014/03", "2014/04", "2014/05",
"2014/06", "2014/07", "2014/08", "2014/09", "2014/10", "2014/11",
"2014/12", "2015/01", "2015/02", "2015/03", "2015/04", "2015/05",
"2015/06", "2015/07", "2015/08", "2015/09", "2015/10", "2015/11",
"2015/12", "2016/01", "2016/02", "2016/03", "2016/04", "2016/05",
"2016/06", "2016/07", "2016/08", "2016/09", "2016/10", "2016/11",
"2016/12", "2017/01", "2017/02", "2017/03", "2017/04", "2017/05",
"2017/06"), .Tsp = c(2014, 2017.41666666667, 12), class = "ts")
检查了多个链接,但仍然不起作用。看不到适合我的解决方案。
我唯一设法用这些数据做的事情没有转换成ts
- 用 ggplot 可视化geom_point
,使用
ggplot(raw_mongolia_monthly, aes(Time_Period, Value)) + geom_point()
谢谢!
解决方案
推荐阅读
- python - pandas:计算两个不同数据帧的列值之间的时间差
- python - 这是过拟合的情况吗?CNN图像分类器
- javascript - 在 DomContentLoaded 之前执行 JS?
- angular - Firebase Functions Deploy:解析函数触发器时出错
- drupal - 页面中 header.html.twig 文件路径中的渲染问题--front.html.twig
- django - Django debug False 阻止访问保存在媒体文件夹中的文件
- python - Python,如何用文本文件中的不同唯一字符串替换文件中的特定字符串?
- flutter - 如何在 Flutter 中使 TextField 底部居中
- python - Keras 预测糖尿病视网膜病变
- vb.net - 性能计数器。如果相同的进程正在运行,我如何访问正确的进程?