1

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.

user3558855
  • 303
  • 4
  • 17
  • Could you simply delete most of this message and replace with "Why does strftime(something, something) produces X in R and Y in Spotfire?"? And is Spotfire consistent with the Spotfire documentation? – Spacedman Feb 15 '19 at 22:06
  • 1
    Isn't this a question to send to Spotfire support? – user2554330 Feb 15 '19 at 23:17
  • user2554330, you may be right that Spotfire support would be the appropriate venue to ask about this. Perhaps I should redirect my question there? Spacedman, that's a fair point. I knew it was long-winded when I was writing it, but wanted an example to demonstrate the type of issue I keep coming across. I am not interested in the strftime function in itself - it was just my most recent example - and I do want to know if SpotFire is consistent with R documentation, but also how to know when it won't be and if there are suggested ways of working having to do with this that I'm not aware of. – user3558855 Feb 15 '19 at 23:55

1 Answers1

2

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

Gaia Paolini
  • 1,044
  • 1
  • 5
  • 4
  • this is the correct answer. TERR is an optimized R engine. if you have specific issues with functions such as `strftime` (just as an example) returning funny data, you'll likely have better success with TIBCO Support. – niko Feb 18 '19 at 19:01
  • also, it may be possible to run your R Studio against TERR instead of the default engine, which may help your development. I believe Visual Studio has support for multiple R engines but I can't comment on R Studio. – niko Feb 18 '19 at 19:05