1

I worked on Tableau and R, I want to forecast school number yearly. I created two calculated field : dataforcast calculated field

DATE(IF [School Year] == { MAX([School Year]) } 
THEN DATEADD('year', 1, [School Year]) ELSE [School Year] END)

School number forecast calculate field but it shows an error:

Error in numeric(h) : vector size cannot be NA/NaN

SCRIPT_REAL("library(forecast); 
x <- .arg1; 
y <- .arg2;  
myts <- ts(.arg1,start=c(2008,1), frequency= 1); 
myforecast <- forecast(myts, h=.arg1[1]); 
monthsts<-length(.arg1);  
append(.arg1[(.arg2[1]+1):monthsts], myforecast$mean, after= monthsts )", 
       SUM([Number of students]) , ATTR([Dateforcast]))
geoidesic
  • 4,649
  • 3
  • 39
  • 59
arwa
  • 13
  • 1
  • 1
  • 5

1 Answers1

-1

In the TabPy Github documentation, you'll see that the following is necessary:

"For a SCRIPT call to Python to be successful, it needs to return a result explicitly specified with the return keyword (highlighted in red)."

enter image description here

Without the return keyword, nothing is brought back to tableau. Hence the NA/NaN error.

Hope this helps!

MonteCarloSims
  • 1,751
  • 1
  • 7
  • 19