2 Replies Latest reply on Mar 29, 2015 10:54 PM by Bora Beran

    how to display an Arima prédiction in Tableau

    Salma Zejli

        

      I want to integrate Tableau desktop with R in orther to display a graph appended to its Arima prediction.To do so, I created a calculated field in Tableau for the shifted date to display it in the X-axis.This is the code:

       

       

      IFNULL(LOOKUP(ATTR([Day]), [Période To Forecast]),ATTR(DATEADD('day',[Période To Forecast], [Day])))

       

          I then created another calculated field to display  it in the Y axis:

       

      SCRIPT_REAL("library(forecast);
      myts <- ts(.arg1)
      arimafit <- auto.arima(myts);
      fcast <- forecast(arimafit, .arg2[1]);
      n<-length(.arg1);
      append(.arg1,fcast$mean, after = n)"
      ,
      Sum
      ([Nb Visiteurs Uniques]),[Période To Forecast
      ])


      I received an error in Tableau telling me that:la fonction script a renvoyé un nombre de résultats inattendus. I tried then to reduce the number of points, so I changed the content of the append function like that:


      append(.arg1[(.arg2[1]+1):n],fcast$mean, after = n-.arg2[1]),


      I received this error: Error in x[1L:after] : only 0's may be mixed with negative subscripts. I searched in the net and understood that there is  a negative term in the .arg1 variable.But the number I'm displaying is positive. Does R interprete the number as being negative? I will be thankful if you can help me resolve this issue. Thanks in advance