Configuring the R Adaptor

This article applies to P2 Server version 4.5.4 and later, and P2 Sentinel 4.1.3 and later.

The R Language infrastructure is available as a separate licensable component in P2 Server. R is an open source programming language and software environment for statistical computing and graphics that is supported by the R Foundation for Statistical Computing.

Note: Before you can use the R Script component, ensure that Microsoft R Open 3.3.3 or later is installed on the same machine as P2 Server.

P2 Server provides access to R via the R Language calculation functions.

Related: RTimeSeries()

Adaptor Overview

The R Adaptor is responsible for executing R scripts for the R Language functions. This adaptor supports 64-bit R engines and allows parallel R script execution by running multiple R adaptors at once with one R engine instance in each.

The R Adaptor differs from other adaptors in that it does not appear in P2 Server Management. Configuring the R Adaptor is done through the ServerConfig.xml, available at:
C:\Program Files\P2 Energy Solutions\P2 Server\Configuration

Here is an example configuration:

<ConfigGroup Name="R Adaptor">
     <Param Key="RHome" Value="C:\Program Files\Microsoft\R Open\R-3.4.0" />
     <Param Key="RRelativePath" Value="bin\x64" />
     <Param Key="RAdaptorEnabled" Value="false" />
     <Param Key="RAdaptorMinPoolSize" Value="2" />
     <Param Key="RAdaptorMaxPoolSize" Value="8" />
     <Param Key="RAdaptorInitTimeout" Value="60" />
     <Param Key="RAdaptorRequestTimeout" Value="600" />
     <CollectionParam Key="RAdaptorEnabledPackages">
        <Value>Package1Name</Value>
        <Value>Package2Name</Value>
     </CollectionParam>
     <CollectionParam Key="RAdaptorDisabledFunctions">
        <Value>Function1Name</Value>
        <Value>Function2Name</Value>
     </CollectionParam>
</ConfigGroup>

Parameters

RHome Main folder of the R installation.
RRelativePath Relative path of the R engine within the RHome folder.
RAdaptorEnabled True or False. Indicates whether the R Adaptor and thus executing R scripts is enabled. Default: false
RAdaptorMinPoolSize The smallest number of R Adaptor instances that will always be available to execute R scripts. Default: 2
RAdaptorMaxPoolSize Largest number of R scripts that the system will attempt to execute simultaneously. Default: 8
RAdaptorInitTimeout Time limit (in seconds) allowed for the R Adaptor to initially set up and configure the R engine before timing out. Default: 60
RAdaptorRequestTimeout Time limit (in seconds) applied to all non-initialization operations against the R Adaptor. Default: 600
RAdaptorDisabledFunctions A collection of additional R functions which are not allowed to be executed in R scripts. The following functions are considered insecure and are already permanently disabled in the R Adaptor: detach(), eval(), file.remove(), install.packages(), library(), require(), shell(), source(), system(), system2(), and unlink(). If there are no additional values in the collection, use:
<CollectionParam Key="RAdaptorDisabledFunctions"/>
or
<CollectionParam Key="RAdaptorDisabledFunctions"></CollectionParam>
RAdaptorEnabledPackages A collection of R packages which will be pre-loaded by the R Adaptor for executing R scripts. If a package is not in this list then it cannot be used inside an R expression. See Installing New Packages below. If there are no values in the collection, use 
<CollectionParam Key="RAdaptorEnabledPackages"/>
or
<CollectionParam Key="RAdaptorEnabledPackages"></CollectionParam>

Installing New Packages

New packages cannot be installed from inside of P2 Explorer, and must be installed by the system administrator using the standard R installation functions.  This has been restricted inside of Explorer so that System Administrators retaiin full control over what R Packages get installed onto the system.

To install new packages:

  1. Download and install the R package onto the P2 Server machine.
  2. Add the name of the new package to the RAdaptorEnabledPackages This will ensure that the R adaptor will load and allow the new R package to be used.
  3. Restart the Data Broker Windows service to force the R adaptor to pick up the changes.

 

One Comment:

  1. Support for R began in P2 Server 4.5.4

Comments are closed