The Register Data Functions dialog is used to configure data functions that allow you to add calculations written in R, or other languages, to your analysis. The data function is executed using a statistical engine such as the TIBCO Enterprise Runtime for R engine, or, if you have access to the corresponding software, you can also use Python, open-source R, SAS, or MATLAB scripts when registering data functions. See the TIBCO Spotfire Service for Python – Installation and Administration Guide or the TIBCO Spotfire Statistics Services - Installation and Administration Guide for information on how to connect to other engines.
The Register Data Functions dialog also allows you to specify which predefined functions in your package repository should be available for end users of TIBCO Spotfire. Once a function has been registered and saved to the library it can be used in any analysis, also by other users than the script author.
To reach the Register Data Functions dialog:
On the menu bar, select Tools > Register data functions.
Option |
Description |
New
Function |
Clears all text fields and list views in the dialog so you can start defining a new data function. |
Open |
Opens a previously saved data function from the library for further configuration. |
Import |
Imports script function definitions (*.sfd) that you have earlier exported to disk, or Python script files (*.py) or R script files (*.r) created using other script editing tools. |
Save |
Saves an edited data function definition to the library. |
Save
As |
Opens the Save as Library Item dialog where you can specify a name and a location in the library where you want the data function definition to be saved. |
Export |
Saves a script function definition to disk so that it can be shared or further edited in other script editing environments. |
Run |
Opens the Edit Parameters dialog so that you can specify settings for the input and output parameters and execute the current data function. This is mostly meant as a shortcut for testing the data function before it is saved to the library, and embedded instances added while testing should be removed from an analysis when you are done, to avoid having unnecessary instances saved in the analysis. Run the saved data function from f(x) - analytic tools or Files and data, or using Insert from the Data Function Properties before saving the analysis in order to be able to synchronize the data function with any updates in the library in the future. See also Data Function Properties. |
Name |
Displays the name of the data function when it has been saved to the library. If the function has not yet been saved, this field will be empty. |
Type |
Selects the type of function to use. The available types depend on which calculation engine you have access to. For predefined functions, select open-source R function. When a function that you want to use from within TIBCO Spotfire has been defined and saved to your package repository in Spotfire Statistics Services, you must write down or remember its name, together with the names of all required input and output parameters. To define a new script, select R script - Open Source R, R script - TIBCO Enterprise Runtime for R, Python script, SAS script or MATLAB script. |
Packages
(separated by semicolons) |
[Available for R scripts run in TIBCO Enterprise Runtime for R, open-source R functions and scripts, and for Python scripts; not available for SAS or MATLAB scripts.] Optional. Specifies any packages to be used by your current data function. For example, if you want to create a data function based on a predefined statistical R function, provide the name of the package and optionally download it from CRAN. Type the exact name of the package where the function is located. (This is only necessary if there is more than one function bearing the same name in the repository, or the packages are not loaded automatically.) For local Python scripts, this field allows you to list Python packages that can be pre-loaded to reduce the time when executing the data function. This field is used in the installed Windows client, if the use of hot spares is enabled. It does not affect the remote service or data functions run in web clients. If you are unsure, leave the field blank. You must still import the package in the script as well as specifying it here. If more than one package is required, separate the package names with semicolons. |
Function
name |
[Available for open-source R functions only, not for scripts.] Specifies the function name. Type the exact name of the function of interest, as it was defined in the Spotfire Statistics Services package repository. |
Description |
Optional but recommended. A description of the data function. This description is stored in the library and can help the end users of the data function to select the proper function. |
Allow
caching |
Specifies that calculations are reused if the same subset of input values has been calculated before. Clear this check box if some of the input data comes from somewhere else than your current analysis and you want a new calculation each time input data changes (even for changes into something that has already been computed before). Input data can change when the input depends on filtered values, marked values, or a property value. For example, if the data function includes a random number generator, you probably do not want to cache a previously generated random number. Instead, calculate a new random number for each refresh of the data function. Another example where you would clear the check box is if the data function includes the current date or time. |
Icon |
Specifies the icon to use in the different interfaces where a data function is shown (for example, in the Files and data flyout, the f(x) flyout and the Data canvas). By selecting a suitable category, you can make it easier for end users to find the right data function in the library. The selected category is automatically added as a keyword when you save the data function to the library. You can choose from a number of predefined category icons, or use a custom Scalable Vector Graphics (SVG) icon. For more information about creating custom icons that work in the Spotfire environment, see Create an icon for your visualization mod on GitHub. |
Script tab
[Available for script type data functions only, not for data functions based on predefined statistical functions.]
Type or paste a script in the specified script type language. You can also import saved *.py or *.r script files using the Import button.
Tip: If you are developing scripts using open-source R or TIBCO Enterprise Runtime for R, you can use RStudio, a full-featured, open-source integrated development environment for working with R code. It is provided independently of Cloud Software Group, Inc. However, you can configure RStudio for the TIBCO Enterprise Runtime for R engine, and to view 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.
You can change the font settings for the script tab using Tools > Options, Fonts and selecting Expression and script editor.
The Script editor provides syntax highlighting and automatic indenting to make writing and reading scripts easier.
Input Parameters tab
Option |
Description |
Parameters |
Lists all input parameters that have been mapped using the Input Parameter dialog. |
Add |
Opens the Input Parameter dialog. |
Edit |
Opens the Input Parameter dialog with the selected input parameter and its current settings available for editing. |
Remove |
Removes the selected input parameter from the list. |
Move
Up |
Moves the selected input parameter up one step. The order of the input parameters in this list determines the order in which the input parameters should be retrieved. |
Move Down |
Moves the selected input parameter down one step. |
Output Parameters tab
Option |
Description |
Parameters |
Lists all output parameters that have been mapped using the Output Parameter dialog. |
Add |
Opens the Output Parameter dialog. |
Edit |
Opens the Output Parameter dialog with the selected output parameter and its current settings available for editing. |
Remove |
Removes the selected output parameter from the list. |
Move
Up |
Moves the selected output parameter up one step. Use this button to place the most important output parameters at the top of the list. |
Move
Down |
Moves the selected output parameter down one step. |