OLAP Server User Guide
MDX Documentation
MDX Functions Reference

MDX / R Integration

Integrating R with icCube is a project in its starting blocks. This integration is based on the renjin project (thanks Alexander Bertram). The idea is starting to investigate several possibilities mainly on data-mining, predictive analysis and advanced calculations.

If you've an interest or want to collaborate on this direction do not hesitate to contact icCube ( support @ iccube . com ) and/or Renjin project directly.

Configuration

By default R support is turned off. It can be activated via the user defined property _ r.active _ in the file icCube.xml.

Usage

The notation R!method( ... ) allows for accessing any R methods from an MDX statement. Note that the conversion of the parameters (as well as the result) is handled automatically by the MDX engine. The following calculated member is computing the natural logarithm of a measure : of PI using JAVA classes:

WITH MEMBER [Measures].[val] AS R!log( [Measures].[Amount] )

R constants can be used accessed the same way. E.g., the following calculated measure is defined as TRUE:

WITH MEMBER [Measures].[val] AS R!is.na( R -> NA )

Note that the sequence operator (e.g., from:to) is not yet supported when passing parameters to R functions. As a workaround, the function seq(from,to) which is equivalent can be used.

Examples

Random values

We can also use R to generate a random vector of normal distributed values. Pay attention, we use the const flag to ensure the vector of random values is the same for each request.

WITH
  /* creates the vector of n normal distributed values */
  CONST FUNCTION randomVector() as R!rnorm(500, mean=0.5, sd=0.25)
  /* quick check that is the same 'random' vector at request level */
  MEMBER mean as randomVector()->mean()
  MEMBER mean2 as randomVector()->mean()
  /* an example to calculate the histogram, us p so the sum is 1.0 */
  MEMBER [p-(,0)]        as randomVector()->phist(NULL,0)
  MEMBER [p-(0,0.25)]    as randomVector()->phist(0,0.25)
  MEMBER [p-(0.25,0.5)]  as randomVector()->phist(0.25,0.5)
  MEMBER [p-(0.5,0.75)]  as randomVector()->phist(0.5,0.75)
  MEMBER [p-(0.75,1.00)] as randomVector()->phist(0.75,1.0)
  MEMBER [p-(1.0,)]      as randomVector()->phist(1,NULL)
SELECT
    [Measures].allmembers - [Measures].members on 0
FROM [MyCube]
    

Installation

The R package (renjin + icCube plugin) is available as a separate download. Once downloaded, unzip the package within the icCube installation directory. You should get new JARs both in the lib (e.g., renjin-core) directory and in the plugins directory (e.g., iccube-plugin-renjin.jar). You'll have to restart the icCube server for the changes to take effect.

Note that when starting the icCube server using icCube.bat or icCube.sh you'll have to update accordingly the JAVA classpath with the new JARs added in the lib directory as described previously. On Windows, the icCube.exe application is using automatically all the JARs from the lib directory.

Configuration

Activation

The R / MDX integration can be (de)activated using the property r.active within the file $install/bin/icCube.xml.

Packages

No specific configuration is required to access R methods from the default base packages. Within the $install/bin/icCube.xml file the userDefinedProperties r.rLibs and r.initScript allows for configuring the access to other R packages.