Details on Edit Script


The Edit Script dialog is used to configure data functions that have been added to an analysis either by using a data function definition stored in the library, or by creating a local data function definition using the Register Data Functions dialog.

To reach the Edit Script dialog:

  1. Locate the data function that you want to edit in the data canvas. Use the search field in the top-left selector if you have many data tables or data functions in the analysis.

  2. Click the settings button on the fx node  (Edit script).

  3. Comment: You can also reach the Edit script dialog using the Data Function Properties dialog.

Option

Description

Name

Displays the name of the data function definition when it has been saved to the library. If the function has not yet been saved, this field will show the name of the data function instance.

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 Spotfire has been defined and saved to your package repository, 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 - Spotfire Enterprise Runtime for R, or Python script.

Packages (separated by semicolons)

[Available for R scripts run in Spotfire® Enterprise Runtime for R (a/k/a TERR™), open-source R functions and scripts, and for Python scripts]

Optional. Specifies any packages to be used by your current data function. See the documentation for the service of interest for more information about packages.

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, or in the R packages deployed to the Spotfire Server for the Spotfire Service for R.

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.

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.

Tip: If you are developing scripts using open-source R or Spotfire 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 Spotfire Enterprise Runtime for R engine, and to view its language reference. Also, you can access the Spotfire Enterprise Runtime for R language reference at the documentation site.

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.

See also:

What are Data Functions?

How to Use a Data Function

How to Register a Data Function

Manage Trust