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.
In TIBCO Spotfire, on the menu bar, select Tools > Register data functions.
Response: The Register Data Functions dialog is displayed.
From the Type drop-down list, select the type of script to use, for example R script - TIBCO Enterprise Runtime for R.
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.
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.
In the Name field, type the name of the function.
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.
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.
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.
Optionally, provide a Description of the function to make it easier to use by others.
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.
If necessary, move the input parameters so that the order in the list reflects the order in which the input parameters should be retrieved.
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.
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.
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:
On the menu bar, select Tools > Options.
Response: The Options dialog is displayed.
Go to the Data Functions page.
Click the Custom URL radio button.
Type the address to the local calculation engine.
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.
Make sure you have the data function script definition you want to export open in the Register Data Functions dialog.
Browse to the location where you want to save the file and type a File name.
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.
In TIBCO Spotfire, on the menu bar, select Tools > Register data functions....
Browse to locate the script function definition.
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.