How to Use a Predefined Data Function


You can use data functions created by a script author in many different places, depending on what the data function does. TIBCO Spotfire Statistics Services provides the possibility for script authors to add scripts based on several different statistical languages. The type of script used determines which statistical engine is used to perform the calculation. As an end user, you do not need to know which language the script is written in, or which engine is used, as long as the system is configured correctly. However, there might be some differences in the available data types or conversion issues when sending data between different systems that you want to be aware of.

Note: Time and Date formats are not directly supported by Spotfire Statistics Services. When sending this type of input to Spotfire Statistics Services you will get the data back in a DateTime (TimeDate) format where a default date or time part has been appended to the original data.

You can use the Currency data type only for data functions intended to use the TIBCO Enterprise Runtime for R engine, but when it is sent to the engine, the data type is converted from Currency to numeric, and when it is returned to Spotfire, it is converted to real. This conversion process can result in a loss of precision for very large values.

To open a data function that produces data:

  1. On the authoring bar, click Files and data .

  2. In the flyout, locate the data function of interest by searching for a suitable name or keyword, or by browsing the library.

  3. Tip: You can find all data functions in the library that open data by entering type:datafunction in the search field. See Searching the Library for more details.

To use a predefined data function as a transformation:

  1. When you add imported data to the analysis, you can apply a transformation to your data. Transformations can be added either when loading the data for the first time or afterwards. See Transforming Data for more information.

  2. In the Transform data dialog, select Data function from the drop-down list and click Insert.

  3. In the Data Functions – Transformation dialog, select the data function to use and click OK.

To map and execute a previously registered data function from the Data Function Properties dialog:

  1. On the menu bar, select Data > Data function properties, and, in the Data Function Properties dialog, click Insert.

    Response: The Data Functions - Select Function dialog is displayed.

  2. Optionally, click on a Keyword or use the search field to limit the number of shown functions in the dialog.

    Comment: For more information about search expressions, see Searching in TIBCO Spotfire.

    Response: Only the functions whose names match the keyword or search expression are shown in the dialog.

  3. Click to select the desired function.

  4. Click OK.

    Response: The Edit Parameters dialog is displayed.

  5. Specify whether to Refresh function automatically.

    Comment: If the check box is selected, a new calculation is performed each time the input parameters change. If the check box is cleared, you must refresh the data function manually.

  6. Specify what to do with the input or output parameters, and then click OK.

    Comment: For a description of the available input and output handlers, see Details on Edit Parameters.

    Response: The function is executed. Depending on how the output parameters were set up, you may get a new or updated data table, new columns or rows, or an updated data table or document property, which can be used to control a variety of settings in your analysis. Click the Notifications icon, located in the upper right part of the TIBCO Spotfire window, for more progress information.

To allow end users to refresh a data function from a text area:

When data functions are executed in the document, an author can configure the analysis so that it is possible to refresh the output by clicking an action link or button in a text area. This can be a way to make it easier for other users of the analysis to find and use the data function. For example, if the data function has been configured to work with filtered rows, many people can access the analysis, filter to their special area of interest and click on a button to receive calculation results relevant for them.

 

  1. Create an analysis that uses the data function, and run the data function from the Data Function Properties dialog, as described above.

    Comment: You must run the data function initially to make the current document aware of the data function.

  2. Create a text area, and then enter edit mode by clicking Edit Text Area, .

  3. Click Insert Action Control, .

    Response: The Action Control dialog is displayed.

  4. In the left pane, click Data Function.

  5. Type the Display text to use on the button or link.

  6. Select the Control type to use.

  7. Click to select the data function of interest from the Available data functions list.

    Comment: Only those data functions that have been executed from within the current document and do not use automatic refresh are available.

  8. Click OK and save the text area.

    Response: The button or link (or image) is added to the text area.

To use the result from a data function to draw a line in a visualization:

Data functions can be used to calculate new data that can be used to do such things as drawing a line in a visualization. This can be accomplished in a variety of ways, but the steps below describe an example where the data function result is presented as two new columns containing coordinate values.

  1. Execute a data function that uses current data columns as input and performs a calculation before the new resulting columns are added to the data table.

    Response: The data function is added to the document, and the result columns are added to the data table.

  2. Create a visualization that can display lines and curves, such as a scatter plot.

    Comment: Line from Column Values cannot draw curves over categorical axes, so make sure that the value columns on both axes are continuous.

  3. Right-click in the visualization and select Properties.

    Comment: You can also select Visualizations > Visualization properties on the menu bar.

    Response: The Visualization Properties dialog is displayed.

  4. Click Lines & Curves.

  5. Click Add and select Line from Column Values.

    Comment: Use this option if the data results are located in one X-values and one Y-values column. If the results from the data function are presented as curve parameters, you should use Curve from Data Table instead. If a curve equation is calculated, use Curve Draw.

    Response: The Line from Column Values dialog is displayed.

  6. Select the Data table with line values.

    Comment: This should be the data table where the result columns were added.

  7. Select the X-values column.

  8. Select the Y-values column.

  9. If desired, select a Sorted by column, to specify a different sort order.

  10. Specify whether to Ignore (skip) empty values or to Split curve at empty values.

  11. Specify whether to use an Automatic or a Custom curve name.

  12. Click OK.

    Response: The curve is added to the visualization.

To refresh a data function:

If you have inserted a data function in your analysis and the underlying data has been changed, you can update the calculation using the same settings as last time without needing to insert the data function again.

  1. On the menu bar, select Data > Data function properties.

    Response: The Data Function Properties dialog is displayed and all data functions that have been executed in the analysis are shown in the Data functions in current analysis list.

  2. Click to select the function of interest in the Data functions in current analysis list.

  3. Click Refresh.

  4. Click Close.

To automatically run the data function when an analysis is opened:

When you add a data function in Spotfire, you can specify whether that data function should run every time the Spotfire analysis is opened. You might want to avoid this option if the data input does not change, and running the data function consumes a lot of time and resources.

However, you might want to set this option if the data input changes frequently and you want the data function to reflect the changes in a  visualization.

  1. Go to one of the dialogs that control data function behavior:

  2. Make sure that the option Refresh function automatically is selected.
    Comment: The method you use to create the data function determines whether this option is set by default. 'Refresh function automatically' is selected by default only when you add a data table from a data function using the Files and data flyout, and if the data function has no input parameters. Under all other circumstances, and regardless of how the data function is added, the option is cleared by default.

    Note: If your analysis contains a cyclic dependency, the data function switches to manual update automatically so it does not get stuck in an update loop.

  3. Configure all data tables in the analysis that are output from the data function to be Linked (individual settings per source) (not Embedded in analysis). You can set this configuration option from Data > Data table properties.

To change parameter settings for a saved data function in an analysis:

  1. On the menu bar, select Data > Data function properties.

    Response: The Data Function Properties dialog is displayed and all data functions that have been executed in the analysis are shown in the Data functions in current analysis list.

  2. Click to select the function of interest in the Data functions in current analysis list.

  3. Click Edit Parameters.

    Response: The Edit Parameters dialog is displayed.

  4. If desired, change whether or not to Refresh function automatically.

  5. Change the Input or Output parameter settings and click OK.

    Response: The data function is updated using the new settings.

To sync a data function with the library:

If a newer version of the data function in the document is available in the library you can click sync to update the data function in the analysis with the changes in the library.

  1. On the menu bar, select Data > Data function properties.

  2. In the Data functions in current analysis list, click to select the function of interest.

  3. Click Sync from Library.

  4. Click Close.

To remove a previously inserted data function from the analysis:

  1. On the menu bar, select Data > Data function properties.

  2. In the Data functions in current analysis list, click to select the function you wish to remove.

  3. Click Delete.

  4. Click Close.

    Response: The data function is removed from the current document but any outputs that were added (columns, data tables, document properties, etc.) will remain until you remove those manually.

To change the address to Spotfire Statistics Services:

The address to Spotfire Statistics Services is normally specified by the TIBCO Spotfire administrator, on a group level. This step instruction shows how an administrator can change the address for a user group. It is also possible to use a local calculation engine (see below).

  1. Login to  TIBCO Spotfire as a user with administration rights.

  2. On the menu bar, select Tools > Administration manager.

    Response: The Administration Manager is displayed.

  3. Click on the Preferences tab.

  4. Click on the group of interest in the Selected group list.

    Response: The preferences and configuration sets for the selected group are displayed.

  5. On the Preferences tab, click the plus sign next to TIBCO Spotfire Statistics Services to expand that group.

  6. Click on StatisticsServices in the TIBCO Spotfire Statistics Services group.

    Response: The currently specified TIBCO Enterprise Runtime for R URL, S-PLUS URL, R URL, SAS® Software URL and MATLAB® URL are shown.

  7. Click Edit.

    Response: The Edit Preferences dialog is displayed.

  8. Type or paste a new URL for Spotfire Statistics Services, for the implementation of your choice.

  9. Click OK.

  10. Click Close.

To delete a saved data function from the library:

If you have administrative rights you can delete a data function using the Library Administration tool.

  1. On the menu bar, select Tools > Library administration.

    Response: The Library Administration dialog is displayed.

  2. Browse to and select the data function of interest.

    Comment: You can use the search field at the top right corner of the dialog to help in locating the data function. (Use 'type:datafunction' as the search expression in the search field to find all data functions.) See Searching the Library for more information about search expressions.

  3. Click Delete.

    Response: A dialog asking you if you are sure you want to delete the data function is displayed. Click Yes and the data function is removed.

  4. Click Close.

To edit the name, description or keywords of a saved data function in the library:

If you have administrative rights you can edit the name, description and keywords of a data function using the Library Administration tool.

  1. On the menu bar, select Tools > Library administration.

    Response: The Library Administration dialog is displayed.

  2. Browse to and select the data function of interest.

    Comment: You can use the search field at the top right corner of the dialog to help in locating the data function. (Use 'type:datafunction' as the search expression in the search field to find all data functions.) See Searching the Library for more information about search expressions.

  3. Click the Edit link next to the Selected Item header in the lower part of the dialog.

    Response: The Edit Properties dialog for the selected data function is displayed.

  4. Change the properties for the data function and click OK.

  5. Click Close.

To recreate a deleted result column:

If you run a data function that creates one or more columns, and then you delete one of the result columns from the analysis, the lost column remains deleted when you refresh the data function. To recreate the lost column, you must run the data function from the Data Function Properties dialog again.

See also:

How to Register a Data Function