What are Data Functions?


Data functions are calculations based on S-PLUS, open-source R, SAS®,  MATLAB® scripts*, or R scripts running under TIBCO Enterprise Runtime for R for Spotfire, which you can make available in the TIBCO Spotfire environment.

Concerning R:

Open-source R is available under separate open source software license terms and is not part of TIBCO Spotfire.  As such, open-source R is not within the scope of your license for TIBCO Spotfire. Open-source R is not supported, maintained, or warranted in any way by TIBCO Software Inc.  Download and use of open-source R is solely at your own discretion and subject to the free open source license terms applicable to open-source R.

See http://support.spotfire.com/sr.asp for information about the TIBCO Spotfire Statistics Services system requirements.

Note: In Spotfire Cloud Analyst, you can use TIBCO Enterprise Runtime for R to create a Data Function or call the engine from the Spotfire Expression Language. However, when you publish an analysis to the Spotfire Cloud, remember that the TERR engine is not available to Analysis Client users. Trying to filter or use other controls that attempt to call the TERR engine in the Spotfire Analysis Client results in an error reporting that TIBCO Spotfire Statistics Services is not available. If you want to use TERR in Spotfire applications that you publish to web-based users, we recommend you use Spotfire Cloud Enterprise instead.

First, define a data function and save it to the library using the Register Data Functions dialog. Second, apply the data function to your analysis. For example, you can use a data function as a transformation step when you add or replace data tables. You can also use it as a separate tool, running it from the Insert > Data Function menu.

You can define an S-PLUS or open-source R data function either from an existing function in the corresponding TIBCO Spotfire Statistics Services package repository, or by writing a script directly in the Register Data Functions dialog, and then running in the appropriate engine.

You can specify input and output parameters when you set up a data function.

To ensure a rapid response and a good user experience, avoid sending very large data sets from Spotfire to a statistical engine, or invoking complex, long-running calculations.

Note: If you are developing scripts using open-source R or 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.

 

Example 1:

A simple conversion of the values in a column from degrees Celsius to degrees Fahrenheit. Although this is easy to accomplish using the Insert Calculated Column tool, it serves as an example simple enough to show input and output parameter handling in more detail.

  1. Assume that the data table in TIBCO Spotfire contains a column with temperatures expressed in degrees Celsius.

  2. First, select Tools > Register Data Functions....

  3. For Type, specify  R script - TIBCO Enterprise Runtime for R from the drop-down list.

  4. Define the script to perform the conversion on the Script tab:
    # Define the convertTemperature function:
    convertTemperature <- function(x)
    {
      x*(9/5) + 32
    }
    # Run the function to produce the output:
    out <- convertTemperature(x);

  5. Define the Input parameter x as a column with the allowed data types Integer and Real.
    df_example_input.png

    Tip: You can select the parameter in the Script tab and use the pop-up menu option Input Parameter to reach the Input Parameter dialog directly.

  6. Define the Output parameter out as a column.
    df_example_output.png

    Tip: You can select the parameter in the Script tab and use the pop-up menu option Output Parameter to reach the Output Parameter dialog directly.
    Note that the output display name will not be propagated to the output column name. The column name is always the output specified by the R script.

  7. Save the data function to the library, as Temperature converter.

  8. To connect the input and output parameters to your current data in TIBCO Spotfire and run the calculation, select Insert > Data Function.

    Comment: You must have data loaded in TIBCO Spotfire to use this functionality.

  9. Click the Temperature converter data function and click OK.

  10. In the Data Functions - Parameters dialog, specify that the input parameter x  should be a column and select the data table and column to convert.
    df_example_input_parameters.pnga

  11. Click the Output tab and specify that the output parameter out  should be handled as a column.
    df_example_output_parameters.png

  12. Click OK.

The data function calculation is performed and a new column is added to the data table. You can change the parameter settings or refresh the calculation later by selecting Edit > Data Functions Properties.

Example 2:

If the function to use is a Principal Component Analysis (PCA) calculation, the input would be a number of numerical data columns retrieved from the current data in TIBCO Spotfire and, optionally, a parameter specifying the percent variation to be preserved by the principal components. The output would include three new data tables (scores, loadings and eigenvalue/explained variance table) and a scalar indicating the number of principal components generated.

See also:

How to Use Data Functions

Details on Register Data Functions

 

* SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.

MATLAB is a trademark or registered trademark of The MathWorks, Inc.