An R Script node is a Calculation node that you can use in a policy model to return a result that is calculated by an
The inputs for an R Script node must correspond to the type of inputs expected by the R Script. The output of an R Script node contains the value calculated by the R script.
The Properties window for an R Script node contains the items that are described in the following table.
Item |
Description |
Notes |
---|---|---|
Path |
Specifies the path to the R script that will run when the policy is executed. |
You can type the path manually, or
you can browse to it by selecting |
Additional sections corresponding to the inputs expected by the R script. |
Specifies the values that will be used in the R script to calculate a result. |
The number of sections displayed in the Properties window is determined by the number of inputs configured in the specified R script. In each section, you can select the The value that you specify should correspond to the type of input expected by the R Script (i.e., a Vector of Values, a Matrix of Values, Data Frame, or a single value that is Numeric, Character, Boolean, or Time & Date). |
You should account for the following behaviors when working with R scripts in policies:
For Data Frame inputs:
The following example illustrates how you can use an R Script node to evaluate certain values in other nodes and return a particular value. Consider the following nodes and connections.
As shown in the following image, you can use the Properties window for the R Script node to select a particular R script that was created using the R script editor. The R script in this example requires three input values: LinerBaseDF, LiningConditionAdjustment, and OnlineMonitoringAdjustment. These input values correspond to variables in the specified R script.
You can see that output values from the predecessor Input nodes have been specified to supply the values required by the R script. When this policy is executed, these values will be used to calculate the result of the R script. The Return Value node then returns the value calculated by the R Script node.
The following example illustrates how you can use a policy to execute an R script that calculates statistical information regarding readings related to a Measurement Location, and then send that information via email message to a designated recipient.
Consider the following R script and corresponding parameters.
This R script calculates the average reading value, count of readings, standard deviation, and most recent reading date of input values provided as a Data Frame.
The following policy is used to provide the input to the R script and to use the results of the R script in subsequent operations.
This policy first filters Measurement Location readings to only those readings recorded within the last 30 days. Then, the filtered readings are sent as a Data Frame input to the R script.
The following image shows the Properties window for the R Script node.
Next, the calculated results returned by the R script are used in a Text node to construct a message that will ultimately be sent via email to a responsible user.
The following image shows the Properties window for the Text node.
The following image shows the full text pattern specified in the Text node.
Copyright © 2018 General Electric Company. All rights reserved.