r - 尝试分解时间序列时出错:非数字参数
问题描述
我是 R 新手,正在做一项任务,我将一些 JSON 数据导入到 (1) 创建时间序列图和 (2) 分解时间序列。这是我正在努力的分解功能。这是有效的...
# Import JSON & convert to data.frame
aor <- fromJSON.....
aor <- as.data.frame......
# Combine the year and month into a date format
aor$date <- as.yearmon(paste(aor$year, aor$month), "%Y %m")
# Ensure data is float not chr
aor$mwh <- as.numeric(aor$mwh)
# Prep the data.frame for time-series analysis by converting to xts
aor <- xts(x = aor, order.by = aor$date)
# Successfully output a time-series graph.
dygraph(aor)
这是到目前为止的 aor 示例...
> aor
mwh date
Jan 2001 " 1.42000" "Jan 2001"
Feb 2001 " 1.28400" "Feb 2001"
Mar 2001 " 1.25800" "Mar 2001"
Apr 2001 " 1.53600" "Apr 2001"
May 2001 " 1.47100" "May 2001"
Jun 2001 " 1.91800" "Jun 2001"
Jul 2001 " 2.37800" "Jul 2001"
> dput(head(aor, 10))
structure(c(" 1.42000", " 1.28400", " 1.25800", " 1.53600",
" 1.47100", " 1.91800", " 2.37800", " 2.47000", " 1.65100",
" 1.58100", "Jan 2001", "Feb 2001", "Mar 2001", "Apr 2001",
"May 2001", "Jun 2001", "Jul 2001", "Aug 2001", "Sep 2001", "Oct 2001"
), .Dim = c(10L, 2L), .Dimnames = list(NULL, c("mwh", "date")))
我认为会产生分解图的代码......
ts <- as.ts(aor)
> ts
mwh date
Jan 1 1.42000 Jan 2001
Feb 1 1.28400 Feb 2001
Mar 1 1.25800 Mar 2001
Apr 1 1.53600 Apr 2001
May 1 1.47100 May 2001
Jun 1 1.91800 Jun 2001
Jul 1 2.37800 Jul 2001
d <- decompose(ts)
plot(d)
尝试分解 ts 时出现此错误...
`-.default`(x,趋势)中的错误:二进制运算符的非数字参数
解决方案
推荐阅读
- css - 我是新来的反应,我正在尝试用反应引导,但我收到了这个错误?
- java - JAVA PROGRAMMING: Linkedlist question Collection c
- sql-server - 登录 SQL Server Management Studio 2008 时如何查看本地服务器的名称?
- python - 逐行提取符号
- android - 无法将数据从片段传递到片段
- java - 必须有 Java 运行时环境 (JRE) 或 Java 开发工具包 (JDK) 才能运行 Eclipse 安装程序
- angular - 如何在angular6中重复表格
- r - 将列条目转换为具有条目计数的列标题
- abap - SAP ABAP 中阻止在导入新软件期间激活字典对象
- excel - 使用 VBA 将 .xls 批量转换为 .xlsx 而不打开工作簿时出现文件格式错误