Importing Data from R Scripts
You can import data directly from an R Script, either by entering the script directly in the task, or by referencing an external script file.
This type of operation may be useful if you want to apply an external script to data before using it in a Rulex workflow, in order to perform a specific operation that requires a low-level programming language, such as deciphering badly formatted text files.
Prerequisites
R software is installed where Rulex is running.
Additional tabs
The following additional tabs are provided:
Documentation tab where you can document your task,
Parametric options tab where you can configure process variables instead of fixed values. Parametric equivalents are expressed in italics in this page (PO).
Procedure
Drag and drop the Import from R script task onto the stage.
Double click the Import from R script task.
Configure the script options as described in the table below.
Save and compute the task.
R bridge options | ||
---|---|---|
Name | PO | Description |
General options | ||
Get R script from file | scriptfromfile | Select this option to import the R script directly from a file, and not by manually entering the R code below. |
Select R script | filename | Click here and browse to the external file, which contains the R script you want to apply. This option will be enabled only if you have selected the Get R script from file option. |
Store output in | outref | Select the type of table that will be populated by the data.frame selected as output in the R script. Possible options are:
|
Name of the output data frame in R script | routputname | Enter the name you want to use in the R script to reference the data Rulex will receive from R. This data will populate the table according to the option selected in Store output in. |
Select file to store R console output | debugfilename | Browse to the text file where the R script console output will be saved after execution of the R Bridge task. |
R Code | rcode | Enter the R script code you want to execute. This text box is enabled only if you have not selected the Get R script from file option. |
Connection options | ||
Select path to Rterm command | rcommand | Browse to the location of the Rterm command. The default path on a Windows system, corresponding to the default value of this option, is “C:/Program Files/R/R-3.3.2/bin/x64/Rterm.exe”. If the path is not correctly specified, the R Bridge task will not work correctly and a warning message will be displayed. The RBridge task cannot compute if another Rterm process is pending. You can monitor this on Windows via the Task Manager (Processes). |
R host | rhostname | Enter the address of the host where R is installed. If Rulex is running on the same desktop where it is installed you can enter localhost. |
R port | rport | Specify the port used for data transfer between Rulex and R (i.e. input table transfer from Rulex to R, output data frame transfer from R to Rulex). System firewall exception Make sure you define an exception in the system firewall on this port, allowing the data exchange between the two applications. Otherwise, the task will not be executed and a warning message will be displayed signaling a communication problem between Rulex and R. |
R port for signals | rportaux | Specify the port used for signal transfer between Rulex and R (i.e. progress bar updates). System firewall exception Make sure you define an exception in the system firewall on this port, allowing the data exchange between the two applications. Otherwise, the task will not be executed and a warning message will be displayed signaling a communication problem between Rulex and R. |
setprogress command
The setprogress command, which updates a progress bar, increasing it by a corresponding progress percentage, can be set via the R code text box, or via a referenced external script.
For instance, if the current progress value is 10 and a setprogress(10) command is executed, the progress bar is increased by (100-10)*10% = 9%, that is to 19%.
If R libraries are referenced in the script (through the “library” R instruction), you should install them previously, in their native R environment, instead of inserting the install.packages instruction directly in the R Code window. However, the install.packages command can be run from Rulex only if Rulex itself is executed with administrative privileges: otherwise, a warning concerning this issue will be raised and the execution will not terminate.