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. When using Python scripts you can either use a local python.exe or a Python service on the 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.) 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 to the library.

    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 the Files and data or the f(x) flyouts, from Data Function Properties > Insert, or, by adding it as a transformation (see How to Use a Data Function for more information).

To use an alternative calculation engine:

These steps are applicable when using a custom calculation engine instead of the TIBCO Spotfire Statistics Services URLs defined by the Spotfire administrator on the server.

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

  2. Go to the Data functions page.

  3. Click Custom URL.

  4. Type or paste the address to the local calculation engine.

  5. Click OK.

To use a specific python.exe as the Python engine:

If you want to run Python-based data functions using a specific python.exe, for example, to test your script using a different version of Python you can change this in the Options dialog.

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

  2. Go to the Data functions page.

  3. Click Use specific python.exe.

  4. Type or paste the address to the local file.

  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 want to add a simple calculation you can create an expression function where you add TERR scripts directly in the expression language by using the TERR_* functions available under Statistical Functions. They can then be used as any other functions in the expression language in calculated columns and custom expressions. However, note that expression functions cannot be shared between different analyses.

See also:

How to Debug a Data Function

Manage Trust

How to Use TERR Tools

How to Use Python Tools