[Resolved] Expression Function error when returning NA values

I have a problem with an Expression Function. 
The function returns a Real; when the first value of the output column is "NA", Spotfire considers the column to contain Booleans, and thus it is impossible to create the calculated column using the Expression Function. The error message is: "TERR script [...] did not return the expected type Real instead returned Boolean."

As a workaround, I put a dummy value in place of the first returned value (in case it's "NA")...

Interestingly, once the calculated column is created, I can modify the code of the Expression Function and make it return "NA" values even for the first value, and it works!

It appears to me that this is a bug; I'm using Spotfire 6.5.3.13. Any advice most welcome!

5 Comments

Thanks for the update!! Works like a charm.
gregori.gerebtzoff - Mar 23, 2016 - 9:26am
In TERR (as in R), the symbol NA refers to a missing value of class "logical" (Spotfire's "Boolean"). You can use either NA_real_ or as.numeric(NA) to make a missing value of class "numeric" (Spotfire's "Real"). TERR's NaN is a IEEE-754 "not-a-number", the result of an indeterminate calculation like 0/0 or Inf-Inf. Missing values and NaN's get treated pretty much the same internally, but mean different things to the user - a missing value means that a datum required for a calculation was not collected while NaN means there was an indeterminate calculation.
wdunlap - Feb 29, 2016 - 12:43pm
Cool, thanks for the update.
wirlybird - Feb 04, 2016 - 4:34am
Thanks a lot wirlybird: returning NaN instead of NA did the trick!
gregori.gerebtzoff - Feb 03, 2016 - 11:44pm
Can you compensate for the non-real value in the script like we would in a calculated column that had a divide-by-zero for instance?
wirlybird - Feb 03, 2016 - 9:52am
View More Comments + Add a Comment
Login