rrstudiospotfiretibcoterr

Inconsistencies of R scripts between RStudio and TibcoSpotfire


When making data functions for Tibco SpotFire - build version 7.8.1.0.9 - I use RStudio - R version 3.5.2 (2018-12-20) - for writing and debugging the functions, and then I copy my code into SpotFire when I am done.

On several occasions, I have noticed inconsistencies between how R code runs between RStudio and SpotFire. Whenever these arise, the results produced by RStudio are consistent with the online R documentation, and those produced by SpotFire are not.

I have not been tracking examples as I go, but I do have my most recent example of this available. Below is a simplified version of that data function. It and the paragraph below it are more in-the-weeds than is ideal for this post, but hopefully it demonstrates the type of issue I keep coming across.

# converts date strings "yyyy-MM-dd" to week number strings "yyyyww",
# where ww is the week number in the year (ISO 8601 convention.)
# dates is a vector (R) or column in a data table (SpotFire)
# containing strings, formatted as "yyyy-MM-dd". In SpotFire,
# the data type for the column is String, not Date.
Week <- strftime(dates, format="%Y%V")

A link to the documentation for R's strftime function is here. RStudio returns values like "201901", which is what the documentation indicates it should for the format argument used. SpotFire returns values like "2019" - no week number info is there at all, against the documentation. If I replace format="%Y%V" with format="%Y%W", RStudio returns values like "201900", which again is what is indicated by the documentation. As far as I can tell, SpotFire returns the values it is supposed to with format="%Y%V" - so I guess internally it changes the inputs in some manner.

My basic question is: How do I get around this sort of thing, and how can I know when/how SpotFire is going to mess with my functions and their variables in some weird manner? E.g., is there some special version of R that Tibco uses that is not the documented R, or is there documentation that Tibco provides for how it's going to internally handle R code?

Thanks for any help.


Solution

  • The short answer is yes. Spotfire natively runs TERR, a special version of R that TIBCO uses. This link gives the main differences but it is not exhaustive: R/4.4.0/doc/html/Differences_Between_TERR_and_R/differences.html

    They are two separate language engines. If you google 'TIBCO TERR' you will find a lot of information. You will find the exact version of TERR you are running in your Spotfire by going to Tools > TERR Tools.

    You can use RStudio and point it to where TERR is installed on your machine, the same way you point it to your R installation. This way you can verify your code does what you expect. It looks in this case that %V is not supported but %W is. You can also use open source R within Spotfire, but then you need a statistics server.

    Gaia