0与负下标混合错误

时间:2016-10-19 08:16:29

标签: r tableau

下面的代码让我在tableau中运行r代码。我使用相同的.arg1 [1:(l-.arg2 [1])]行来使用它的类似版本来预测其他变量,但由于某种原因,这段代码不断抛出错误:&#34 ; .arg1 [1:(l - .arg2 [1])]中的错误:只有0可以与负下标混合。"我已经看到一些关于此错误的帖子提到混合负面下标,但我不确定如何解决它。我尝试创建一个名为endTrain< - l - .arg2 [1]的变量,然后使用它,但我仍然遇到了同样的错误。在下面的代码中.arg1 = data1,.arg2 = 20,和.arg3 = data3。任何提示将不胜感激。

代码:

SCRIPT_REAL("library(forecast);
         library(scales);
l<-length(.arg1);

##Training data
TTT_Train<-.arg1[1:(l-.arg2[1])];

##Squishing Training Data
sq_TTT_Train<-squish(TTT_Train,c(0,quantile(TTT_Train,     0.70,na.rm=TRUE)),only.finite = TRUE);

##Predictors
PTdept_Train<-.arg3[1:(l-.arg2[1])];
PTdept_xreg<-.arg3[(l-.arg2[1]+1):l];

##Boxcox
TTTlambda <- BoxCox.lambda(sq_TTT_Train);

##Fitting Model
TTT_Arima.fit <- auto.arima(sq_TTT_Train, lambda = TTTlambda,     xreg=PTdept_Train, stepwise=FALSE, approximation = FALSE );

##Forecasting Model
TTT_Acast<-forecast(TTT_Arima.fit,xreg=PTdept_xreg, h=.arg2[1]); 

n<-length(TTT_Train);
TTT_Train[n]=.arg1[l];


append(TTT_Train,TTT_Acast$mean, after = n)",

MEDIAN([data1]),5,[data3])


Data:

dput(data1)
c(63.4372765313806, 30.7020714950508, 61.3762171505454, 67.8098119137313, 
9.90608767587409, 28.2730722109119, 30.5860381744545, 28.5296011735178, 
51.2349910904615, 39.2643897519848, 33.562104814554, 75.7182794817487, 
75.5716262744966, 99.9292128067995, 223.486781951025, 174.357671384739, 
123.572182606563, 81.5962797794171, 62.479987835206, 50.5884333924931, 
106.189812089455, 34.7439347196729, 39.307897419613, 128.066517894731, 
79.3899466114849, 103.986918416265, 174.846986741853, 45.8670416798064, 
32.4510716913794, 29.4709729789433, 22.3799384193593, 34.4048754256376, 
42.593174426779, 66.0600799777264, 80.6798342785803, 117.959229286774, 
-0.437468072813784, 181.962186246928, 74.9786273378472, 339.559155565098, 
228.58525661881, 23.7874697390277, 61.286048922751, 37.9758323399058, 
103.800201056574, 179.916980912313, 43.6877805636916, 11.9667131950155, 
-2.11813031844491, 55.2312544374417)


dput(data3)
c(12.7403717000914, -7.19663803975745, 76.4326912044527, 17.3970323526101, 
7.71359391450461, 58.4774730447122, 40.3155187526539, 107.36312318686, 
53.1703584063198, 111.513879865192, 122.645596924123, 227.778043946375, 
231.561809230002, 61.2564233472132, 231.834312838835, 108.282526002386, 
301.200801619446, 243.809945961832, 410.407674646823, 462.11214896637, 
312.342855191562, 514.55916495712, 452.320943372023, 414.482997139952, 
149.388172905569, 159.977489462244, 179.433048283881, 122.66074523787, 
43.5372892561067, 107.422455826792, 93.5957469916635, 103.263693676251, 
123.598364527977, 185.924336009535, 238.331634927816, 127.943742943097, 
330.249162542821, 637.196201693695, 653.783515619174, 286.384850664611, 
574.207679665304, 450.729429013028, 502.061722085684, 545.109088924087, 
319.357227809765, 575.684384244634, 273.300471939596, 294.507816528409, 
363.3267881272, 314.613593895384)

0 个答案:

没有答案