我是Tableau的新手
我写了此代码
SCRIPT_REAL("
library(forecast)
data <- ts(.arg2,start=c(2003,1),frequency=12);
ARIMAfit <- auto.arima(log10(data),approximation=FALSE,trace=FALSE);
fcast <- forecast(ARIMAfit,h=5);
",
ATTR( MONTH( [New] ) ), SUM( [Number of Tractor Sold] ) )
Tableau显示了"计算是有效的",但是一旦我试图绘制我的预测结果显示。
the result returned by the script function is of an unexpected type
任何类型的帮助或剪切代码对我都非常有帮助。谢谢...
尝试一下它将起作用;
SCRIPT_REAL("
library(forecast)
data <- ts(.arg1,start=c(2003,1),frequency=12);
ARIMAfit <- auto.arima(log10(data),approximation=FALSE,trace=FALSE);
fcast <- forecast(ARIMAfit,h=5);", SUM( [Number of Tractor Sold] ) )
另外,如果您愿意,可以添加RMSE和MAE结果 -
请在下面找到示例 -
SCRIPT_STR(
"rmse <- function(error){ sqrt(mean(error^2))}
mae <- function(error){ mean(abs(error))}
tsfa1 = ts(.arg1,frequency=12,start = c(2012,6))
library(forecast)
fit1 = Arima(tsfa1, order=c(0,0,0),seasonal=c(1,1,0), include.mean = FALSE,include.drift=TRUE)
fcast<- forecast(fit1)
paste(fcast$fit, fcast$residuals, sep='~')",SUM([NET]))