How to Register a Data Function


You can use data functions to enhance the functionality of TIBCO Spotfire. Below are a few examples of where and how data functions can be defined and applied. Note that you can use the local TIBCO Enterprise Runtime for R (TERR) engine, or you can specify a TERR service, if it is deployed on a node available to your Spotfire Server. Alternatively, you can send requests to a TIBCO Spotfire Statistics Services server. (See your administrator about specifying the address to TIBCO Spotfire Statistics Services). If you are using open-source R,  you can send requests to the TIBCO Spotfire Statistics Services Local Adapter as explained below. See also What are Data Functions? and Introduction for Data Function Authors.

To register a data function in Spotfire:

This example shows how to register a TERR data function, but you would use the same procedure to register data functions using other calculation engines.

  1. In TIBCO Spotfire, on the menu bar, select Tools > Register data functions.

    Response: The Register Data Functions dialog is displayed.

  2. From the Type drop-down list, select the type of script to use, for example R script - TIBCO Enterprise Runtime for R.

  3. Optionally, if you want to include a predefined function from a statistical package, in the Packages field, type the exact name of the package where the function is located.

  4. Comment: Packages are not available for data functions based on MATLAB or SAS. Packages provide a on opportunity to create a data function based on a predefined statistical R, TERR or S-PLUS function by using a downloaded package.

  5. In the Name field, type the name of the function.

  6. Comment: If you are using packages stored on Spotfire Statistics Services, then remember that TIBCO Spotfire cannot find a function in the Spotfire Statistics Services package repository unless the name is exactly the same.

  7. When registering data functions based on predefined functions from statistical packages, in the Function name field, type the exact name of the function of interest, as it was defined in the Spotfire Statistics Services package repository.

  8. Comment: TIBCO Spotfire will not be able to locate the function in the Spotfire Statistics Services package repository unless the name is exactly the same.

    Comment: This step is not applicable for script-based data functions.

  9. Optionally, provide a Description of the function to make it easier to use by others.

  10. On the Input Parameters tab, add all required input parameters.

    Comment: How the input parameters should be handled is defined upon execution of the data function.

  11. If necessary, move the input parameters so that the order in the list reflects the order in which the input parameters should be retrieved.

  12. On the Output Parameters tab, add all required output parameters.

    Comment: How the output parameters should be handled is defined upon execution of the data function.

  13. Save the data function.

    Comment: You can specify keywords upon saving that will help in locating the function in the library at a later stage.

    Response: The registered data function is saved in the library.

  14. Click Close.

    Comment: The data function can now be added to an analysis by running it from Data Function Properties > Insert, by adding it using the Files and data flyout (if it produces data), or, by adding it as a transformation (see How to Use a Predefined Data Function for more information).

To use an alternative calculation engine, e.g., TIBCO Spotfire® Statistics Services Local Adapter:

  1. On the menu bar, select Tools > Options.

    Response: The Options dialog is displayed.

  2. Go to the Data Functions page.

  3. Click the Custom URL radio button.

  4. Type the address to the local calculation engine.

  5. Click OK.

To export a data function definition:

You can export a script/data function definition to disk if you want to share it with others or if you prefer to edit scripts in other script editing environments.

  1. Make sure you have the data function script definition you want to export open in the Register Data Functions dialog.

  2. Click Export.

  3. Browse to the location where you want to save the file and type a File name.

  4. Click Save.

To import a data function definition:

You can import a script function definition that you have previously exported to disk or have written using another script editing tool. The script file should use the extension *.sfd.

  1. In TIBCO Spotfire, on the menu bar, select Tools > Register data functions....

  2. Click Import.

  3. Browse to locate the script function definition.

  4. Click Open.

Tip: If you only want to add simple calculations you can also add TERR scripts directly in the expression language by using the TERR_* functions available under Statistical Functions in calculated columns or custom expressions.

See also:

How to Debug a Data Function

Script and Data Function Trust