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.

  1. Download RStudio

    RStudio is the development environment for R. The Open Source version is free.

    Download: https://www.rstudio.com/products/RStudio/#Desk

  2. Find your TERR engine.

    Mine is located at C:\Program Files (x86)\TIBCO\Spotfire\7.0.0\Modules\TIBCO Enterprise Runtime for R_3.1.0.19\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

  3. Point RStudio to TERR Engine
    1. In RStudio go to Tools -> Global Options…
    2. In General menu select the R version by clicking Change

    3. 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_3.1.0.19\engine\

    4. Restart RStudio for the changes to take effect.
    5. Verify TERR is running in RStudio.

      After the restart, in the RStudio Console, you should be able to see the version of TERR running.

  4. 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)

  5. In RStudio Console load the RData file by executing the following line of code:

  6. Run your R script in RStudio using the same inputs as when you would run it in the Spotfire TERR Data Function.
Written by Anna Drummond
"Choose a job you love, and you will never have to work a day in your life." -Confucius