Have you ever come across problems and errors while running the TERR scripts in Spotfire Data Functions which you didn’t have while running the same code as an R script outside Spotfire? There is a way to troubleshoot this issue by debugging your TERR code outside of Spotfire, i.e., in RStudio. Generally speaking, you need to enable your RStudio to run the TERRengine instead of R. Then, you want to be able to access your TERR Data Function Input Parameters from RStudio so that you can run and debug your TERR script there. How to do all that? It’s not that complicted. Please follow the steps below.
If you already have RStudio installed on your machine, go to Step 2.
If your RStudio is already running TERR, go to Step 4.
- Download RStudio
RStudio is the development environment for R. The Open Source version is free.
- Find your TERR engine.
Mine is located at C:\Program Files (x86)\TIBCO\Spotfire\7.0.0\Modules\TIBCO Enterprise Runtime for R_184.108.40.206\engine
The TERR engine folder may be hidden. If that’s the case you need to “Show Hiden Folders” on your machine. Follow the steps listed here: https://support.microsoft.com/en-us/help/14201/windows-show-hidden-files#show-hidden-files=windows-7
- Point RStudio to TERR Engine
- In RStudio go to Tools -> Global Options…
- In General menu select the R version by clicking Change
- Click Browse and navigate to the TERR engine location.
In my case it is C:\Program Files (x86)\TIBCO\Spotfire\7.0.0\Modules\TIBCO Enterprise Runtime for R_220.127.116.11\engine\
- Restart RStudio for the changes to take effect.
- Verify TERR is running in RStudio.
After the restart, in the RStudio Console, you should be able to see the version of TERR running.
- In Spotfire, save the Data Function Input Parameters to an RData file.
You can do that by placing the following line of code in your Data Function script. Note: the script has to run successfully, i.e., without errors, for the data to get saved.
save(list=ls(), file=”C:/Users/Anna/Documents/regression.RData”, RFormat=TRUE)
- In RStudio Console load the RData file by executing the following line of code:
- Run your R script in RStudio using the same inputs as when you would run it in the Spotfire TERR Data Function.