This project has moved and is read-only. For the latest updates, please go here.
<h1>
<button value="TRUE" /><p><strong>Off-the-Shelf R Scripts</strong></p>
<button value="FALSE" /><p><a href="/wikipage?title=R%20Script%20%22Shelf%22&amp;referringTitle=Home">"On-the-Shelf" Metric Expressions</a>
</h1>
<table border="1">
<tbody>
<tr>
<td><strong>R Analytic</strong></td>
<td><strong>Description</strong></td>
<td><strong>R Script</strong></td>
<td><strong>Documentation</strong></td>
</tr>
<tr>
<td><strong>Seasonal Forecasting</strong></td>
<td>
<p>Forecasts seasonal data using the Linear Regression algorithm</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile1" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837999"><font color="#2e8bcc">SeasonalForecasting.R</font></a></td>
<td><a title="" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837998" target="blank"><img src="https://home.microstrategy.com/layouts/IMAGES/icpdf.gif" alt="" border="0" /></a><a id="wikiFile2" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837998"><font color="#2e8bcc">SeasonalForecasting.pdf</font></a></td>
</tr>
<tr>
<td><strong>ARIMA</strong></td>
<td>
<p>Forecasts time series data using the ARIMA algorithm (Auto-Regression Integrated with Moving Average)</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile3" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837986"><font color="#2e8bcc">ARIMA.R</font></a></td>
<td><a title="" href="https://home.microstrategy.com/wiki/Knowledge%20Documents/DMX/Rscripts/Documents/ARIMA.pdf" target="blank"><img src="https://home.microstrategy.com/layouts/IMAGES/icpdf.gif" alt="" border="0" /></a><a id="wikiFile4" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837984"><font color="#2e8bcc">ARIMA.pdf</font></a><br /> <a title="" href="https://home.microstrategy.com/wiki/Knowledge%20Documents/DMX/Rscripts/Documents/ARIMA.pdf" target="blank"><img src="https://home.microstrategy.com/layouts/IMAGES/icdoc.gif" alt="" border="0" /></a><a id="wikiFile4b" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837971"><font color="#2e8bcc">ARIMAMetricExpression.rtf</font></a></td>
</tr>
<tr>
<td><strong>Clustering</strong></td>
<td>
<p>Clustering using the k-Mediods algorithm</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile5" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837960"><font color="#2e8bcc">kMedoidsClustering.R</font></a></td>
<td><img src="https://home.microstrategy.com/layouts/IMAGES/icpdf.gif" alt="" border="0" /><a id="wikiFile6" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837969">kMedoidsClustering.pdf</a><br /> <img src="https://home.microstrategy.com/layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile7" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837970"><font color="#2e8bcc">StorePerformance.mstr</font></a><br /> <img src="https://home.microstrategy.com/_layouts/IMAGES/icxls.gif" alt="" border="0" /><a id="wikiFile8" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=837965"><font color="#2e8bcc">Cluster&amp;RegionRevenue.xlsx</font></a></td>
</tr>
<tr>
<td><strong>Naive Bayes</strong></td>
<td>
<p>Classification using the&nbsp;Naive Bayes&nbsp;algorithm&nbsp;</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile9" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815743"><font color="#2e8bcc">NaiveBayes.R</font></a></td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icpdf.gif" alt="" border="0" /><a id="wikiFile10" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815742"><font color="#2e8bcc">Na&iuml;veBayes.pdf</font></a></td>
</tr>
<tr>
<td><strong>Neural Network</strong></td>
<td>
<p>Classification using&nbsp;Neural Networks</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile11" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815745"><font color="#2e8bcc">NeuralNetwork.R</font></a></td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icpdf.gif" alt="" border="0" /><a id="wikiFile12" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815744">NeuralNetwork.pdf</a></td>
</tr>
<tr>
<td><strong>Random Forests</strong></td>
<td>
<p>Classification using the Random Forests algorithm</p>
</td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icgen.gif" alt="" border="0" /><a id="wikiFile13" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815746"><font color="#2e8bcc">RandomForest.R</font></a></td>
<td><img src="https://home.microstrategy.com/_layouts/IMAGES/icpdf.gif" alt="" border="0" /><a id="wikiFile14" href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=815747"><font color="#2e8bcc">RandomForest.pdf</font></a></td>
</tr>
</tbody>
</table>
<h2>How to use:</h2>
<p style="padding-left: 30px;"><span style="text-decoration: underline;">Prerequisites:</span> &nbsp;In addition to MicroStrategy, make sure you have installed R (available from <a href="http://r-project.org" target="blank">www.r-project.org</a>)&nbsp;and the RScripts functions (available from the <a href="https://rintegrationpack.codeplex.com/releases/view/117668">Downloads</a>&nbsp;tab on this site). &nbsp;More&nbsp;information can be found in the <a href="http://download-codeplex.sec.s-msft.com/Download?ProjectName=rintegrationpack&amp;DownloadId=791498" target="blank"> R Integration Pack User Guide</a>, but the key details are included here:</p>
<ul>
<li>R and the RScript functions must be installed anywhere calculations are performed by MicroStrategy. &nbsp;
<ul>
<li>MicroStrategy Analytics Enterprise:
<ul>
<li>Always the Intelligence Server, since this is where jobs execute for&nbsp;users running MicroStrategy Web, MicroStrategy Office, MicroStrategy Mobile and MicroStrategy Developer. &nbsp;</li>
<li>MicroStrategy Developer, for when R analytics are deployed as Derived Metrics in 3-tier or when connected 2-tier.</li>
<li>NOTE: &nbsp;For the Intelligence Server and Developer, after installing the RScript functions on those systems, you'll still need to add the functions to each project's schema. &nbsp;So, please be sure to run the Configuration &nbsp;Wizard to&nbsp;add the new functions to each project where R Analytics will be deployed. &nbsp;</li>
</ul>
</li>
<li>MicroStrategy Analytics Desktop
<ul>
<li>NOTE: Running&nbsp;Configuration Wizard is not required for MicroStrategy Analytics Desktop.</li>
</ul>
</li>
<li>MicroStrategy Cloud customers can contact the MicroStrategy Cloud team for including R in their Clould instances.</li>
<li>MicroStrategy Analytics Express: &nbsp;The R Integration Pack is currently NOT supported with MicroStrategy Analytics Express.</li>
</ul>
</li>
<li>NOTE: &nbsp;The MicroStrategyR Package and it's deployR utility are NOT required to use these scripts, because they already have had their analytic signature captured into the comment block at the top of the R Script. &nbsp;The MicroStrategyR Package and it's deployR utility are only required by R Script developers in order to prepare the R Script for deployment to MicroStrategy. This step&nbsp;has already been done with these Off-the-Shelf R Analytics.</li>
</ul>
<ol>
<li>Download the R Script and place it in the RScripts folder, usually&nbsp;C:\Program Files (x86)\R Integration Pack\RScripts. &nbsp;You should also download the documentation provided for more details about how the script is meant to be used.</li>
<li>Open the RScript (using any text editor or an R console), find the MicroStrategy Header block at the top of the script and copy the metric expression(s) for the analytic output(s) you wish to deploy to MicroStrategy. &nbsp;</li>
</ol>
<p style="padding-left: 60px;">For example, here's the MicroStrategy Header block from the SeasonalForecasting.R script&nbsp;that comes with the R Integration Pack installation.&nbsp; The metric expression for the Forecast output can be found in <strong>bold</strong>:</p>
<p style="padding-left: 60px;"><code><span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#MICROSTRATEGYBEGIN</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#RVAR Target -input -numeric -vector</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#RVAR Trend -input -numeric -vector</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#RVAR Season -input -vector</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#RVAR FileName -parameter StringParam9</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#RVAR Forecast -output -numeric -vector #Metric Expression: </span><strong style="font-family: Verdana,Arial,Helvetica,sans-serif;">RScript&lt;RScriptFile="SeasonalForecasting.R", InputNames="Target, Trend, Season", StringParam9=""&gt;(Target, Trend, Season)</strong><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#</span><br /> <span style="font-family: Verdana,Arial,Helvetica,sans-serif;">#MICROSTRATEGYEND</span></code></p>
<ol start="3">
<li>Paste the metric expression into any metric editor</li>
<li>Replace the inputs to the metric with the appropriate existing metrics in your project.</li>
<li>Once the metric is validated, you can use it on your report, documents and dashboards, just like any other metric.</li>
</ol>
<h2>Share your scripts:</h2>
<p>We'd like to encourage everyone in the community to use and share these R Scripts. &nbsp;Have you written an R Script you'd like to share with the rest of the community? &nbsp;That would be great!&nbsp;&nbsp;</p>
<p>If you have a R Script you'd like to contribute, please email your script and it's documentation to <a href="mailto:rpechter@microstrategy.com">rpechter@microstrategy.com</a>. &nbsp;We'll test it to confirm its ready for general use by others. Once accepted, we'll add it to this page.</p>
<h3>Code Disclaimer:&nbsp;&nbsp;&nbsp;</h3>
<p>This page provides programming examples.&nbsp; MicroStrategy grants you a nonexclusive copyright license to use all programming code examples from which you can use or&nbsp;generate similar function tailored to your own specific needs.&nbsp; All sample code is provided for illustrative purposes only. These examples have not been thoroughly tested under all conditions. MicroStrategy, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.&nbsp; All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.</p>

Last edited Jun 24, 2014 at 7:20 AM by rpechter, version 1

Comments

No comments yet.