R 尝试分解时间序列时出错:非数值参数
我是R新手,正在做一项工作,在这里我导入一些JSON数据(1)创建一个时间序列图(2)分解时间序列。这是我正在努力的分解函数。这里是什么工作R 尝试分解时间序列时出错:非数值参数,r,time-series,R,Time Series,我是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(ao
# 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)
我以为会产生分解图的代码
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
mwh日期
2001年1月1日14.2万2001年1月
2001年2月1日28400
2001年3月1日1.25800
2001年4月1日153600
2001年5月1日147100
2001年6月1日191800
七月一日237800二零零一年七月
您好,您可以使用dput
共享您的数据吗:只需键入dput(head(aor,10))
并将结果发布到您的问题中。@Cettt谢谢,我刚刚这么做了。在您提供的数据中,mwh
列不是数字,而是带前导空格的字符。这可能就是问题所在。您好,您可以使用dput
共享您的数据吗:只需键入dput(head(aor,10))
,然后将结果发布到您的问题中。@Cettt谢谢,我刚刚这么做了。在您提供的数据中,mwh
列不是数字,而是带前导空格的字符。这可能就是问题所在。
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)