RScript Transform

image_pdfimage_print

Related links: R Installation, R Installation of External Packages

R is a free software programming language and a software environment for statistical computing. It can be used for predictive analysis but also for a variety of other use cases. Jedox now includes an RScript transform type that executes an arbitrary script in R, based on the input data from one or several Jedox Integrator Sources.

RScript transform represents the linkage between Jedox Integrator and the open source statistical software R. Thereby, it is possible to operate any statistical calculation on one or several data sources within Jedox Integrator.

The RScript transform has four components:

  • Data source
  • External packages
  • Name of result set
  • RScript
Data Source

This component can be an extract or transform for the corresponding Jedox Integrator project and has to be selected in the Data Source field. Subsequently, the input is passed to RScript as a variable with the same name as the data source.

External packages

All external R-packages that are used in the RScript have to be declared here in a list. For more information, see R Installation of External Packages.

Name of result set

The result of the calculation within the RScript must be a vector or a data frame, i.e., a list of vectors, factors, and/or matrices all having the same length. In order for Jedox Integrator to locate the result, the name of the variable containing the result has to be filled in here.

RScript

The code for the calculation composed in the R programming language has to be implemented here. Variables created in the Jedox Integrator project can be incorporated in the RScript as well. For further information about R language, visit http://cran.r-project.org/doc/manuals/r-release/R-lang.html.  

Example: calculating quantiles

Input data: E_Cubedata  
RScript:

Result:  

 

Some remarks:
  • Note that the usage of R libraries/commands with graphical output is not supported in RScript transforms.
  • For huge data volume, it is possible to allocate additional memory for the R engine. The R command memory.limit(<size>) requests a new memory limit in Mb. For example, to request a memory limit of 4000 Mb, you would enter memory.limit(4000)
  • Each line of the R script must be a complete command and subsequent lines must have the prefix “@“.
  • Automatic line completion (as in R Console) is not possible. This is especially relevant for IF and FOR statements.

Examples:

while (i<=12}) {ProductType[i] <- levels(data$Product)[1]; i<-i+1}

or

while (i<=12})
@{ProductType[i] <- levels(data$Product)[1];
@i<-i+1}
 

Each RScript row should have only one R expression, which is generally the case in R. However, unlike the R console, there is no error returned if there are several expressions that are separated by spaces. For example, the expression xxxx a<-1 yyy returns no error.

If there are several valid expressions, only the first valid expression is executed. For example, there is no error for the expression x<-1 y<-1, but a value will only be assigned to x.

image_pdfimage_print
Was this post helpful?
NoYes (0 rating, 4 votes)
Loading...