How to Create an Expression Function


Use the Expression Functions dialog to register a function in the Spotfire expression language that is based on TIBCO Enterprise Runtime for R. In this step-by-step instruction, we have added an example of how you type a script to create a temperature conversion function.

Note: If you are developing scripts using TIBCO Enterprise Runtime for R, we recommend that you use RStudio, a full-featured, open-source integrated development environment for working with R code. It is provided independently of TIBCO Software Inc. You can configure RStudio to use the TIBCO Enterprise Runtime for R engine and to display its language reference. Also, you can access the TIBCO Enterprise Runtime for R language reference at https://docs.tibco.com/products/tibco-enterprise-runtime-for-r.

  1. In TIBCO Spotfire, select Edit > Data Function Properties (G)

  2. Click the Expression Functions tab.
    Response: The Data Function Properties dialog is displayed.

  3. Click New.
    Response: The Expression Function dialog is displayed.

  4. Type a Name for your Expression Function.
    Comment: The name of the Expression Function appears when you browse the function list.

  5. Type a Description for your Expression Function.
    Optionally: The description of the Expression Function is displayed when you browse the function list.

  6. In the Script field, type the following script to create a temperature conversion function:
    # Define the FahrenheitToCelcius function:
    FahrenheitToCelcius <- function(TempCelcius)
    {
     TempFahrenheit <- TempCelcius * (9/5) + 32
     TempFahrenheit
     }
    # Run the function to produce the output
    output <- FahrenheitToCelcius(TempCelcius = input1)
    Comment: Alternatively, run a built-in function from TIBCO Enterprise Runtime for R.

  7. Select the Category in which to place the function in the function list.

  8. Select Return type to define the Spotfire data type that the script should return

 

See also:

How to Edit an Expression Function