R Execute (DB)

To configure R Execute, connect a valid data source to the R Execute operator. An intermediate operator also constitutes a data source for R Execute.

Information at a Glance

Category Tools
Data source type DB
Sends output to other operators No
Data processing tool R engine

R Execute (DB) is for database data only. For Hadoop data, use the R Execute (HD) operator.

For information about configuring and using this operator, see R Execute.

Input

Specify that you require the input dataset by referring to an R object called alpine_input in the script. This is a data frame object.

You might choose not to use the input dataset (by not referring to alpine_input in the script), in which case the data is not read in to R.

  • If the input is a preceding operator, the preceding operator runs, but the data is not transferred to R if you do not use alpine_input in the script.
  • If the preceding operator is a data source (a database table), the database query does not run, saving execution time.
Note: Some kind of a data source must be specified, even if you do not use the input dataset in the R code. This is because you might still generate an output data frame, and the data frame must be stored in the same data store type as the one selected for the input (that is, database output for a database input). Also, it must be the same specific data store (the same database).


Restrictions

See the topic "R Execute Prerequisites" in TIBCO® Data Science Team Studio Installation and Administration for information about package, system, and server requirements.

Configuration

Parameter Description
Notes Any notes or helpful information about this operator's parameter settings. When you enter content in the Notes field, a yellow asterisk is displayed on the operator.
R Script

The R Script to execute. Select Define Clause to specify the R script.

See: Define R Script Dialog Box.

Output Schema Specifies the database schema to contain the table representation of the R Execute output data frame.
Output Table Specifies the name of the database table, within the schema defined above, where the table representation of the R Execute output data frame is stored.
Drop if Exists
  • If Yes (the default), drop the existing table of the same name and create a new one.
  • If No, stop the flow and alert the user that an error has occurred.
Pass Output Table Required only if R Execute is not a terminal operator.

Specify whether to pass the R Execute output to the next operator.

This option is important if you want to R Execute the operator's output to the next operator.

If Pass Output Table is set to Yes, then the Result Table Structure details must be configured.

Default value: No

Result Table Structure

Specify the table structure of the operator output to pass to the next operator.

This option dynamically pulls the values from the alpine_output variable in the R script. The values do not populate until you have run the R script once.

Enabled only if Pass Output File is set to Yes.

For more information, see Edit Table Columns Dialog Box.

The following code provides an example of how to use alpine_output:

print("hello")
foo = c("setosa", "virginica", "versicolor")
alpine_output = data.frame(class = foo, 
predicted_class = foo)

Output

Visual Output
The table is stored whether Pass Output Table is set to Yes, and whether the Results Table Structure is provided. The Pass Output Table and Results Table Structure combination is used only to check the integrity of the flow in case the R Execute operator is followed by another operator.

If the alpine_output object does not exist in your R code, then the output is not generated. If you set Pass Output Table to Yes, and if the R script does not contain a reference to the alpine_output object, then the flow fails at runtime, and an error message is displayed for this inconsistency.

Data



If you create an alpine_output object in the R code, then the R Execute operator output displays the output data frame (persisted in the database) in the results console in the Data tab.

R-Console Output



If your R code included functions that printed output to the R console, then the output is displayed in the results console in the R-Console Output tab.
Note: The R Execute operator's console printing behavior is a bit different from the R console or RStudio behavior. Normally, if you have a statement in the R code that reads summary(alpine_input), it is shown in the R console or RStudio console. However, because R Execute is capturing the console output into an object (which is executed in R using R's capture.output function), you must wrap such calls using the print() function. For example, instead of summary(alpine_input), specify print(summary(alpine_input)). This is a limitation of how R's capture.output function works.
R-Script



Your R code is shown in the results console in the R-Script tab.

Output to Succeeding Operators
Describe any data output to the database/cluster or that which is passed on to the next operator.