3 Replies Latest reply on Oct 27, 2019 5:45 PM by Nathan Mannheimer

    Error while using forecast package from R

    Nellie Rajarova


      I am trying to forecast using auto.arima from forecast package in R. I am running both R and tableau on my local windows m/c. Have configured Rserve and tested the connectionRserveconn.png

      Here is my code snippet :




      result = data.frame(sumq = .arg1, Date = .arg2,Holiday = .arg3,WeekDay = .arg4,WeekEnd = .arg5)

      result$Date = as.Date(result$Date, format = "%Y-%m-%d")

      Train <- result[which(result$Date<="2019-06-01"),]

      Test <- result[which(result$Date>"2019-06-01"),]

      y <- ts(Train$Quantity, frequency=7)

      z <- fourier(ts(Train, frequency=365.25), K=5)

      zf <- fourier(ts(Test, frequency=365.25), K=5, h=150)

      fit <- auto.arima(y, xreg=cbind(z,Train$Holiday,Train$WeekDay), seasonal=TRUE)

      fc <- forecast(fit, xreg=cbind(zf,Test$Holiday,Test$WeekDay), h=150)


      output <- fcData$Point.Forecast

      ', SUM([Sum Q]), ATTR([Date]), ATTR([Holiday]), ATTR([Week Day]), ATTR([Week End])



      I keep getting this error

      Unable to complete action . An error occurred while communicating with the External Service.

                      Error in ts(Train$Quantity, frequency = 7) :  'ts' object must have one or more observations. 


      I have read this link which gives an explanation about scoping issues but my runs fine on R studio.  I get the above-mentioned error when I run Rscript in tableau desktop.

      Any thoughts about this?