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.
To use S-PLUS, SAS, or MATLAB, you must access these engines via Spotfire Statistics Services.
To use open-source R, you can access it either from an installation of Spotfire Statistics Services Local Adapter using a locally-installed R engine, or from an engine that you have installed, that is running under TIBCO Spotfire Statistics Services.
To use TIBCO Enterprise Runtime for R, you can use it either from the engine provided in your Spotfire installation, or from an engine installed on TIBCO Spotfire Statistics Services.
Concerning R:
For more information on using R with Spotfire Statistics Services Local Adapter, see the README file included with the Statistics Services Local Adapter. (Other third-party calculation tools can be added using the TIBCO Spotfire API.)
For information on using R with Spotfire Statistics Services, see the TIBCO Spotfire Statistics Services Installation and Administration Guide .
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 Cloud Software Group, 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.
For S-PLUS functions, use the S-PLUS engine.
For R functions, use the TIBCO Enterprise Runtime for R engine or the open-source R engine.
For SAS or MATLAB engines, you can access them only using scripts, and only if you have a working installation of the selected software available.
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.
To create and run an R script data function in a TIBCO Enterprise Runtime for R Engine:
Assume that the data table in TIBCO Spotfire contains a column with temperatures expressed in degrees Celsius.
First, select Tools > Register Data Functions....
For Type, specify R script - TIBCO Enterprise Runtime for R from the drop-down list.
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);
Define the Input parameter
x as a column with the allowed data types Integer and Real.
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.
Define the Output parameter
out as a column.
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.
Save the data function to the library, as Temperature converter.
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.
Click the Temperature converter data function and click OK.
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.
a
Click the Output
tab and specify that the output parameter out
should be handled as a column.
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:
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.