user3558855
user3558855

Reputation: 313

Tibco SpotFire - checking for drop-down list "(none)" option with R data function

I am using Tibco Spotfire. In a text area, I have added a drop-down list via Insert property control with the following relevant parameters:

The purpose of the property control is to provide an input to a data function coded using R. The data function basically performs some sums over an input data table, where the items summed over are filtered via the property control prior to summing.

I wanted a (None) alternative as an option to avoid filtering if the user so chooses. However, I don't know how to check for whether the (None) option is selected. E.g., let's say, in the R function, the variable linked to the property control is called var_1. I want some code that says:

# pseudo R code
# Note: the code below is to demonstrate my question, it's not the exact shape of the code I'm actually using.
if (var_1 == (None)) { # this is the line I don't know how to express, since I don't know how Tibco populates a (None) value
    do not filter stuff.
}

For that if statement, I have tried:

Whichever I choose, the summations, which are supposed to include everything in this case, include nothing.

Normally I could figure this out by just printing var_1's data type to the console after choosing (None) in the dropdown. When I try that, no console output pops up anywhere.

What data does SpotFire populate var_1 with if (none) is chosen, or more to the point, what is the if statement I need here?

Thanks.

Upvotes: 0

Views: 1722

Answers (1)

Gaia Paolini
Gaia Paolini

Reputation: 1462

It should have been NA. Potentially it was unset the first time you tried.

A useful way of debugging such situations is:

  1. place a statement like this: save.image('C:/Debug/myscript.RData') as a first statement of your TERR script, where C:/Debug is just an example of a folder. As long as it exists, any name is fine.
  2. run your script within Spotfire to generate the image file, does not matter if it gives an error, as long as it makes it past that statement
  3. copy and paste your script into RStudio pointing at TERR
  4. replace the save.image with load (or just double-click on the image file)
  5. run the script line by line and/or inspect the environment, where you should see var_1.

In order to open RStudio on TERR, you can go, from within Spotfire, to Tools>TERR Tools> Launch RStudio IDE. It will open RStudio pointing to the TERR version you are currently running within Spotfire. You can verify it by running the 'version' statement.

Upvotes: 0

Related Questions