Execute R (R Scripting)
SynopsisExecutes a R script.
Before using this operator you need to specify the path to your R installation under Tools -> Preferences -> R Scripting. Your R installation has to include the 'data.table' package.
This operator executes the script specified as parameter. The arguments of the script correspond to the input ports, where example sets are converted to data frames. Analogously, the values returned by the script are delivered at the output ports of the operator, where data frames are converted to example sets.
The console output of R is shown in the Log View (View -> Show View -> Log).
The Script operator can have multiple inputs. An input must be either an example set, a file object or an R object which was generated by an 'Execute R' operator.
The Script operator can have multiple outputs. An output can be either an example set, a file object or an R object generated by this operator.
The R script to execute. Define a function with name 'rm_main' with as many arguments as connected input ports or alternatively the ellipsis arguments ('...') to use a dynamic number of attributes. The return values of the function 'rm_main' are delivered to the connected output ports. Entries from the data type 'data frame' are converted to example sets; files are converted to File Objects, other R objects are serialized and can be used by other 'Execute R' operators or stored in the repository. Serialized R objects have to be smaller than 2 GB.
If you pass an example set to your script through an input port, the meta data of the example set (types and roles) is available in the script. You can access it by the metaData list object in R. The names of top components in the list are identical to the arguments from the rm_main() function. Each component will contain the name of all attributes defined by that input argument and its type and role. To access or change a specific meta data entry use metaData$inputArgument$attributeName$type or metaData$inputArgument$attributeName$role. Please note that changes to the meta data have to be made with the 'superassignment' operator <<-.
For more information about the meta data handling in an R operator check the tutorial process 'Meta data handling' below.Range: text
Training and applying a linear model in R
The polynomial data set is split in two parts. The first part is used by the 'Execute R' operator to train a linear model in R. The calculated model is passed on to the second 'Execute R' operator and applied there on the second part of the data set.
Generating probability density functions for different probability functions in R
This script generates sample points for some statistical density functions and returns them as an example set.
Reading an example set from a file using R
This tutorial process uses the 'Execute R' operator to save example data in a csv file. The second 'Execute R' operator receives this file, reads the data and returns a part of the data to the output port. The result is an example set.
Meta data handling
This tutorial process shows how to access the meta data of incoming example sets inside a 'Execute R' operator. It also explains how to set the meta data for the outcoming example sets.